Closed psdewar closed 3 years ago
Hey @psdewar2 a preview swipe is the same as a user generated swipe so you can use any of the regular callbacks (i.e. onRowDidClose
, onRowClose
, etc) see more here https://github.com/jemise111/react-native-swipe-list-view/blob/master/docs/SwipeListView.md
Hey @jemise111 thanks for the info. Thinking about it further, the above scenario I described was a bit oversimplified. I want to update state meant to persist across sessions. In other words:
onRowDidClose
, for example, would be called every time a user closes a row, which is not exactly ideal. I would have used previewFirstRow
to take care of this, but it is deprecated. I could still use a toggle which would determine what the previewOpenValue
would be (a non-zero value the first time, then zero all other times after that), but do you have any alternative suggestions?
Also, none of these work as I expected when a preview occurs, but work perfectly when a swipe is done manually.
onRowOpen
onRowClose
onRowDidOpen
onRowDidClose
Is this by design?
@psdewar2 Oh man idk what happened the first time around but you're 100% right. Those props are not supported on a preview. I added a new prop that will hopefully take care of your issue called onPreviewEnd
in v3.2.6. Here it is in action:
const onPreviewEnd = () => {
console.log('onPreviewEnd');
};
return (
<View style={styles.container}>
<SwipeListView
data={listData}
renderItem={renderItem}
renderHiddenItem={renderHiddenItem}
leftOpenValue={75}
rightOpenValue={-150}
previewRowKey={'0'}
previewOpenValue={-40}
previewOpenDelay={3000}
onRowDidOpen={onRowDidOpen}
onPreviewEnd={onPreviewEnd}
/>
</View>
);
https://user-images.githubusercontent.com/4265163/105635127-fd843400-5e26-11eb-848b-81d704e293ce.mov
thanks man, this is exactly what I was looking for!
@jemise111 could you add the prop to types for TypeScript support?
I would like to update state after a preview has occurred. Is there an easy way to do this (i.e. with a callback)?