I am new to react. I need help in disabling a button for 5 seconds in react js for my project and then re enable it back.
here is my code,
constructor (props) {
super(props);
this.onLaunchClicked = this.onLaunchClicked.bind(this);
this.state = {
isButtonDisabled: false
}
}
onLaunchClicked (event) {
event.preventDefault();
this.setState({
isButtonDisabled: true
});
return this.props.onLaunchClicked();
}
render () {
return (
<div className="client-playtest-state">
<button className="btn bg-success" onClick={this.onLaunchClicked}
disabled={this.state.isButtonDisabled}>LAUNCH</button>
</div>
);
}