Last active
July 17, 2019 15:45
-
-
Save yoneda/edea4e68c7b64042586062c29cc0b805 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test extends React.Component{ | |
constructor(){ | |
super(); | |
this.state = {toggle:false} | |
this.updateToggle = this.updateToggle.bind(this); | |
} | |
updateToggle(flag){ | |
this.setState({toggle:flag}); | |
} | |
render(){ | |
return( | |
<div> | |
<button onClick={()=>this.updateToggle(!this.state.toggle)}>button</button> | |
<p>{this.state.toggle ? "on" : "off" }</p> | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment