[Solved] Disabling the back button and refresh button using reactjs [closed]


You need to use state variables to enable and disable button.
Look in below enable if you click reset or reload it will toggle

class App extends React.Component{
  state = {
    isResetDisable: false,
    isReloadDisable: false,
  }
  handleButtonPress(token){
     console.log(token+" "+"pressed")
  }
  render(){
    return(
     <div>
         <div>
            <a onClick={()=>this.setState({isResetDisable: !this.state.isResetDisable})}> Click Reset lable to toggle button
            </a>
                <input disabled={this.state.isResetDisable}  type="button" value={this.state.isResetDisable ? 'Reset Disabled' : 'Reset Enable'} onClick={()=>{this.handleButtonPress('reset')}}/>
         </div>       
         
           
         <div>
          
           <a onClick={()=>this.setState({isReloadDisable: !this.state.isReloadDisable})}> Click Reload lable to toggle button
            </a>
                <input disabled={this.state.isReloadDisable}  type="button" value={this.state.isReloadDisable ? 'Reload Disabled' : 'Reload Enable'} onClick={()=>this.handleButtonPress('reload')}/>
                
         </div>
         
     </div>
    )
  }
}

ReactDOM.render(<App />, document.getElementById('root'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"></div>

solved Disabling the back button and refresh button using reactjs [closed]