Undo
Undo is opt-in. Add undoEnabled to a Root when the deck exposes undo or
back-swipe UX.
When enabled, each successful swipe stores one key/index/direction metadata
entry in a LIFO undo stack. Lookups use a key-to-index map for the current
data, and invalid entries are pruned when data or keys change.
When omitted, successful swipes do not store undo metadata, canUndo stays
false, and actions.undo() returns false.
Undo Button
Undo Motion
Use SwipeDeckUndoMotion to customize how a restored card enters.
Available recipes:
SwipeDeckUndoMotion.spring(options?): restores with ReanimatedwithSpring.SwipeDeckUndoMotion.timing(options?): restores with deterministicwithTiming.
Both recipes accept:
from: 'auto' | 'left' | 'right':autoreturns from the original swipe direction.entryDistance: number or layout callback for the offscreen start distance.
timing also accepts duration and easing. Its default duration is 0, so
the card is restored immediately unless you opt into custom motion. spring
accepts springConfig.
Precedence
undoMotion is replacement-based:
- factory
undoMotionfromcreateSwipeDeck({ undoMotion }) Root undoMotion, replacing the factory default for that Root- per-call recipe passed to
actions.undo(recipe)
Undo is callback-safe. If a React Native press event is passed to undo, the
event argument is ignored.
