How to close currentSwiper when onPress button
hi all I want to close curent swiper when i onPress button on Item FlatList
i want to close all open swiper when new swiper is open
`Solution for you both (phuongdevapp & Shailesh), Please follow this; Step 1. .... constructor(props) { super(props); this.state = { currentlyOpenSwipeable: null, } } ... Step 2. ... const rightButtons = [ <TouchableHighlight onPress={() => this.state.currentlyOpenSwipeable.recenter()}><Text>Close</Text> </TouchableHighlight>, <TouchableHighlight onPress={() => yourCustomMethod()}><Text>Another Button</Text></TouchableHighlight> ];
Step 3. ... <Swipeable onRef = {ref => this.swipe = ref} onRightButtonsOpenRelease = { (event, gestureState, swipe) => { if (this.state.currentlyOpenSwipeable && this.state.currentlyOpenSwipeable !== swipe) { this.state.currentlyOpenSwipeable.recenter(); } this.setState({ currentlyOpenSwipeable: swipe }); } } onRightButtonsCloseRelease = {() => this.setState({ currentlyOpenSwipeable: null }) } rightButtons={rightButtons}> [ADD YOUR LIST HERE] </Swipeable> ....`
@kapsona it's too slow...
@kapsona don't use currentlyOpenSwipeable as state it slow down the performance instead use as this.currentlyOpenSwipeable = null in constructor