Last active
August 11, 2017 09:29
-
-
Save erikras/8f628b678064dde4290c0c8f0ff229c6 to your computer and use it in GitHub Desktop.
React Performance Anti-Pattern: Creating Functions in render() - problem.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 } | |
} | |
render() { | |
return <div> | |
<MyCustomButton onClick={() => this.setState({ clicked:true })}> | |
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