Created
August 11, 2017 09:28
-
-
Save erikras/8201485b359c9f8b2b5a9bdb5e511f52 to your computer and use it in GitHub Desktop.
React Performance Anti-Pattern: Creating Functions in render() - attempt.js
This file contains hidden or 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
| import MyCustomButton from './ui/MyCustomButton' | |
| class MyClicker extends Component { | |
| constructor() { | |
| super() | |
| this.state = { clicked: false } | |
| } | |
| handleClick() { | |
| this.setState({ clicked: true }) | |
| } | |
| render() { | |
| return <div> | |
| <MyCustomButton onClick={this.handleClick.bind(this)}> | |
| Click Me | |
| </MyCustomButton> | |
| {this.state.clicked && <div>Nice work!</div>} | |
| </div> | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment