Skip to main content

<SwipeListView /> API

A List that renders <SwipeRow />s

Props

PropNotesTypeSignature (func)Default
dataList of objects to be passed into the renderItem and renderHiddenItem functions. Each item must include a unique key property or keyExtractor must be implemented to ensure full functionality.array
useSectionListRender list using React Native's SectionListboolfalse
renderItemHow to render a row in a FlatList. Should return a valid React Element.func{ rowData: any, rowMap: { string: SwipeRowRef } } : ReactElement
renderHiddenItemHow to render a hidden row in a FlatList (renders behind the row). Should return a valid React Element. This is required unless renderItem returns a <SwipeRow> (see Per Row Behavior).func{ rowData: any, rowMap: { string: SwipeRowRef } } : ReactElement
leftOpenValueTranslateX value for opening the row to the left (positive number)number0
rightOpenValueTranslateX value for opening the row to the right (negative number)number0
leftActivationValueTranslateX value for firing onLeftActionStatusChange (positive number)number
rightActivationValueTranslateX value for firing onRightActionStatusChange (negative number)number
leftActionValueTranslateX value for left action to which the row will be shifted after gesture releasenumber
rightActionValueTranslateX value for right action to which the row will be shifted after gesture releasenumber
initialLeftActionStateInitial value for left action state (default is false)bool
initialRightActionStateInitial value for right action state (default is false)bool
closeOnRowPressShould open rows be closed when a row is pressedbooltrue
closeOnRowOpenShould open rows be closed when another row is openedbooltrue
closeOnRowBeginSwipeShould open rows be closed when a row begins to swipe openboolfalse
closeOnScrollShould open rows be closed when the listView begins scrollingbooltrue
disableLeftSwipeDisable ability to swipe the row leftboolfalse
disableRightSwipeDisable ability to swipe the row rightboolfalse
stopLeftSwipeTranslateX value for stop the row to the left (positive number). This number is the stop value corresponding to the leftOpenValue (while the row is swiping in the right direction)number
stopRightSwipeTranslateX value for stop the row to the right (negative number). This number is the stop value corresponding to the rightOpenValue (while the row is swiping in the left direction)number
directionalDistanceChangeThresholdChange the sensitivity of the rownumber2
swipeToOpenPercentWhat % of the left/right openValue does the user need to swipe past to trigger the row opening.number50
swipeToClosePercentWhat % of the left/right openValue does the user need to swipe past to trigger the row closing.number50
swipeToOpenVelocityContributionDescribes how much the ending velocity of the gesture affects whether the swipe will result in the item being closed or open. A velocity factor of 0 (the default) means that the velocity will have no bearing on whether the swipe settles on a closed or open position and it'll just take into consideration the swipeToOpenPercent. Ideal values for this prop tend to be between 5 and 15.number0
recalculateHiddenLayoutEnable hidden row onLayout calculations to run always. By default, hidden row size calculations are only done on the first onLayout event for performance reasons. Passing true here will cause calculations to run on every onLayout event. You may want to do this if your rows' sizes can change. One case is a SwipeListView with rows of different heights and an options to delete rows.boolfalse
swipeGestureBeganCalled when a swipe row is animating swipefunc{ rowKey: string } : void
swipeGestureEndedCalled when user has ended their swipe gesture. v4: event is now an RNGH GestureStateChangeEvent<PanGestureHandlerEventPayload>; the v3 gestureState field is removed (velocity/translation live on event, with velocityX in px/s).func{ rowKey: string; data: { translateX: number; direction: 'left' | 'right'; event: GestureStateChangeEvent } } : void
onRowOpenCalled when a swipe row is animating open. This has a param of toValue which is the new X value the row (after it has opened). This can be used to calculate which direction the row has been swiped open.func{ rowKey: string, rowMap: { string: SwipeRowRef }, toValue: number } : void
onRowDidOpenCalled when a swipe row has animated openfunc{ rowKey: string, rowMap: { string: SwipeRowRef }, toValue: number } : void
onRowCloseCalled when a swipe row is animating closedfunc{ rowKey: string, rowMap: { string: SwipeRowRef } } : void
onRowDidCloseCalled when a swipe row has animated closedfunc{ rowKey: string, rowMap: { string: SwipeRowRef } } : void
onLeftActionStatusChangeCalled once when swipe value crosses the leftActivationValuefunc{ data: { isActivated: boolean, value: number, key: string } } : void
onRightActionStatusChangeCalled once when swipe value crosses the rightActivationValuefunc{ data: { isActivated: boolean, value: number, key: string } } : void
onLeftActionCalled when row shifted to leftActivationValuefunc{ } : void
onRightActionCalled when row shifted to rightActivationValuefunc{ } : void
onScrollEnabledCalled when scrolling has been enabled/disabledfunc{ isEnabled: bool } : void
swipeRowStyleStyles for the parent wrapper View of the SwipeRowobject
listViewRefCalled when the underlying list ref is set and passes a ref to the FlatList/SectionList. e.g. listViewRef={ ref => (this.listRef = ref) }func{ ref: FlatList | SectionList } : void
previewRowKeyShould the row with this key do a slide out preview to show that the list is swipeablestring
previewDurationDuration of the slide out preview animationnumber
previewRepeatShould the animation repeatboolfalse
previewRepeatDelayDelay between each preview repeat in millisecondsnumber1000
previewOpenValueTranslateX value for the slide out preview animation.number0.5 * props.rightOpenValue
previewOpenDelayAdd some delay before opening the preview row. Can be useful when you have enter animation.number
frictionFriction for the open / close animation. Controls "bounciness"/overshoot. Same scale as v3 — mapped to the Reanimated spring through React Native's Origami conversion, so the feel is unchanged.number7
tensionTension for the open / close animation. Controls speed. Same scale as v3 (see friction).number40
restSpeedThresholdRest speed threshold for the open / close spring.number0.001
restDisplacementThresholdRest displacement threshold for the open / close spring.number0.001
onSwipeValueChangeCallback invoked any time the translateX value of a row changes. Crosses to the JS thread every frame — prefer each row's swipeAnimatedValue (see <SwipeRow />).func{ swipeData: { key: string, value: number, direction: 'left' | 'right', isOpen: bool } } : void
shouldItemUpdateCallback to determine whether component should updatefunc{ currentItem: any, newItem: any }
onPreviewEndCallback that runs after row swipe preview is finishedfunc{ } : void

See FlatList for all other inherited props.

Imperative API

A ref to SwipeListView exposes:

MethodNotes
closeAllOpenRows()Animate every open row closed.
manuallyOpenAllRows(toValue)Animate every row to the given translateX value.

Removed props

These were ListView-era or no-ops under Reanimated and are removed in v4. Passing them logs a one-time dev warning. See the migration guide.

Removed propReplacement
dataSourcedata (FlatList) / sections (SectionList)
renderRowrenderItem
renderHiddenRowrenderHiddenItem
renderListViewnone
previewFirstRowpreviewRowKey
previewRowIndexpreviewRowKey
useFlatListnone — FlatList is the default
useAnimatedListnone — the list is always animated
useNativeDrivernone — everything runs on the UI thread