Skip to content Skip to sidebar Skip to footer

React-native-router-flux Scene Render Multiple Times

So I use react-native-router-flux and here is my scene And I have this button which will rou

Solution 1:

you can try to give delay if the button has been clicked, put local state like this:

constructor() {
    super()
    this.state = {
      inClick: false
    }
  }

and add this function :

onClickButton = () => {
    this.setState({ inClick: true })
    Actions.register()
    setTimeout(function() { this.setState({inClick: false}); }.bind(this), 2000);
  }

and in your button should be like this :

<Button warning block style={styles.button} onPress={ !this.state.inClick ? this.onClickButton : null}>

Hope that can help you, thanks :)


Solution 2:

I think the only way is to disable the button if it has been clicked , there's a prop called disabled in react native button.

function handleButtonClick(){
  this.setState({ disabled: true });
  Actions.changePassword();
}


<Button onPress={()=> this.handleButtonClick()} disabled={this.state.disabled} />

Post a Comment for "React-native-router-flux Scene Render Multiple Times"