React Native Prevent Double Tap

后端 未结 10 632
醉梦人生
醉梦人生 2020-12-30 02:22

I have a TouchableHighlight wrapping a Text block that when tapped, opens a new scene (which I\'m using react-native-router-flux).
It\'s all wo

10条回答
  •  北海茫月
    2020-12-30 02:42

    I fixed this bug by creating a module which calls a function only once in the passed interval.

    Example: If you wish to navigate from Home -> About And you press the About button twice in say 400 ms.

    navigateToAbout = () => dispatch(NavigationActions.navigate({routeName: 'About'}))
    
    const pressHandler = callOnce(navigateToAbout,400);
    
     ...
    
    The module will take care that it calls navigateToAbout only once in 400 ms.
    

    Here is the link to the NPM module: https://www.npmjs.com/package/call-once-in-interval

提交回复
热议问题