React Native Prevent Double Tap

后端 未结 10 664
醉梦人生
醉梦人生 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:56

    I fixed using this lodash method below,

    Step 1

    import { debounce } from 'lodash';
    

    Step 2

    Put this code inside the constructor

    this.loginClick = debounce(this.loginClick .bind(this), 1000, {
                leading: true,
                trailing: false,
    });
    

    Step 3

    Write on your onPress button like this

    onPress={() => this.props.skipDebounce ? this.props.loginClick : this.loginClick ()}
    

    Thanks,

提交回复
热议问题