React Native Prevent Double Tap

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

    Perhaps you could use the new disable-feature introduced for touchable elements in 0.22? I'm thinking something like this:

    Component

     this._touchable = component}
                        onPress={() => this.yourMethod()}/>
    

    Method

    yourMethod() {
        var touchable = this._touchable;
        touchable.disabled = {true};
    
        //what you actually want your TouchableHighlight to do
    }
    

    I haven't tried it myself. So I'm not sure if it works.

提交回复
热议问题