dancormier / react-native-swipeout

iOS-style swipeout buttons behind component
MIT License
2.62k stars 645 forks source link

Calling setState with scroll scrollEnabled argument prevents the swipeoutButtons from opening #327

Open Lelelo1 opened 5 years ago

Lelelo1 commented 5 years ago

<Swipeout right={this.renderSwipeoutButtons} buttonsWidth={44} scroll={(scrollEnabled) => { this.setState({ scrollEnable }); }} > </Swipeout>

This causes the flatlist to rerender all the items - preventing them from being opened. How to solve it?

martakielpinska commented 5 years ago

Instead of setting state on your entire screen/component, set the "native prop" of the list. This fixed the issue for me. You need to add ref prop to your flatList first.

this.myFlatList.setNativeProps({scrollEnabled: true/false})