RiffleHandle
Defined in: react/useRiffle.ts:36
What useRiffle returns: the imperative handle plus a pair of prop
getters that wire whatever markup you render to the engine.
Example
Section titled “Example”import { useRiffle } from '@rpxl/riffle/react'
function Stack({ films }: { films: { title: string }[] }) { const riffle = useRiffle({ count: films.length, cardWidth: 300, cardHeight: 400 }) return <div {...riffle.getRootProps()} />}Extends
Section titled “Extends”Pick<AdapterHandle,"instance"|"subscribe"|"getSnapshot"|"on"|"next"|"prev"|"goTo">
Properties
Section titled “Properties”instance
Section titled “instance”
readonlyinstance:Riffle|null
Defined in: adapter.ts:26
The live engine, or null before the container mounts and after it unmounts.
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”getCardProps()
Section titled “getCardProps()”getCardProps<
P>(index,props?):P&object
Defined in: react/useRiffle.ts:50
Props for the card at index. Your own props win, except ref, which
is composed. Pass a stable ref: one whose identity changes every render
re-registers that card with the engine on every render too. Harmless
(registerCard is idempotent for the same element), but wasted work.
Type Parameters
Section titled “Type Parameters”P extends ElementProps
Parameters
Section titled “Parameters”number
props?
Section titled “props?”P
Returns
Section titled “Returns”P & object
getRootProps()
Section titled “getRootProps()”getRootProps<
P>(props?):P&object
Defined in: react/useRiffle.ts:41
Props for the stack container. Your own props win, except ref, which is composed.
Type Parameters
Section titled “Type Parameters”P extends ElementProps
Parameters
Section titled “Parameters”props?
Section titled “props?”P
Returns
Section titled “Returns”P & object
getSnapshot()
Section titled “getSnapshot()”getSnapshot():
RiffleSnapshot
Defined in: adapter.ts:68
Referentially stable while nothing has changed, including across mount.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”goTo()
Section titled “goTo()”goTo(
index,opts?):void
Defined in: adapter.ts:76
Moves to index, animated unless opts.animate is false. A no-op while unmounted.
Parameters
Section titled “Parameters”number
animate?
Section titled “animate?”boolean
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”next()
Section titled “next()”next():
void
Defined in: adapter.ts:72
Advances to the next card, animated. A no-op while unmounted.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”on<
K>(event,fn): () =>void
Defined in: adapter.ts:70
Subscribes to one engine event. Returns an unsubscribe function; a no-op while unmounted.
Type Parameters
Section titled “Type Parameters”K extends keyof RiffleEventMap
Parameters
Section titled “Parameters”K
(payload) => void
Returns
Section titled “Returns”() => void
Inherited from
Section titled “Inherited from”prev()
Section titled “prev()”prev():
void
Defined in: adapter.ts:74
Moves to the previous card, animated. A no-op while unmounted.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”subscribe()
Section titled “subscribe()”subscribe(
listener): () =>void
Defined in: adapter.ts:66
Notified whenever getSnapshot() would return a new value. Returns an unsubscribe function.
Parameters
Section titled “Parameters”listener
Section titled “listener”() => void
Returns
Section titled “Returns”() => void