react-native-swipeout
react-native-swipeout copied to clipboard
how can i close all opened swipe、only can open one swipe at the same time?
i wish can close an opened swipe,the way ? if i swipe a row's button, when i swipe at another row, i hope close other swipe, how ? @dancormier
+1 I'm looking to close the open swipeout item when scrolling the Scrollview
I think it will work with onOpen, _close method in Swipeout and componentWillReceiveProps lifecycle in ListView item component.
+1, now i am directly use a ref to call _close
+1. using _close for now.
Check out the example
https://github.com/dancormier/react-native-swipeout/blob/master/example/index.ios.js
@hufeng i am directly call _close too, but it can not work, can you show your code?
+1. I'm using _close too.
@xuanpyco Hi, can you provide me with your solution? Becuase I use ref, call _close and it does not work. Thanks in advance
@olejka91 I ended up a solution as following.
class ListItem extends Component {
_onSwipeOpen = () => {
this.props.onSwipeOpen(this.swipeInstance);
}
render() {
return (
<SwipeOut
ref={instance => this.swipeInstance = instance}
onOpen={this._onSwipeOpen}
/>
);
}
}
class MyList extends Component {
_onSwipeOpen = (swipeInstance) => {
if(this.currentlyOpenSwipe && this.currentlyOpenSwipe !== swipeInstance) {
this.currentlyOpenSwipe._close();
}
this.currentlyOpenSwipe = swipeInstance;
}
_renderRow = () => {
return (
<ListItem
onSwipeOpen={this._onSwipeOpen}
/>
);
}
render(){
return (
<ListView
renderRow={this._renderRow}
/>
}
}
@xuanpyco I just replaced this library with a react-native-swipe-list-view. Thanks for reply
thanks @xuanpyco sir, your solution worked for me.