react-native-swipeable
react-native-swipeable copied to clipboard
Swipe performance
Hi,
I used your component to achieve a swipe list view, but the performance seems not well on the device. I used onRightButtonsOpenRelease
to close swipe when its parent scrolls, and used onSwipeStart
and onSwipeRelease
to close one row when the other is swiping. All codes are from your example.
Any ideas to improve the performance issue?
Cheers,
Hey @wangdicoder, do you have any ideas for how performance can be improved? That's a great place to start. jshanson7 is one person and I'm sure he'd appreciate the help!
In my case, I increased performance by debouncing the swipe handlers.
I also have noticed performance issues on android devices. I don't have many callbacks, only these:
- onSwipeStart
- onSwipeRelease
- onLeftActionActivate
- onLeftActionDeactivate
- onLeftActionComplete
- onRightButtonsActivate
- onRightButtonsDeactivate
And they don't seem to be called too often. It's weird that I have my swipeable component working very well on iOS, but it's slow on Android
I have the similar problem, when I add onRightButtonsOpenRelease function to Swipe component, the performance suddenly went bad in my device.
Anyone found any solution or workaround to this problem?
As @peterpme suggested:
In my case, I increased performance by debouncing the swipe handlers.
Worked for me very well using lodash debounce with a 100ms wait:
import { debounce } from 'lodash';
<Swipeable
onSwipeStart={() => {
// ...
}}
/>
// Debounce using lodash debounce:
<Swipeable
onSwipeStart={debounce(() => {
// ...
}, 100)}
/>