Created
April 2, 2019 11:18
-
-
Save buglessir/41be29e13c26b7af0aa59e7338507730 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
import React, { PureComponent } from 'react'; | |
import { render } from 'react-dom'; | |
class App extends PureComponent { | |
constructor(props) { | |
super(props); | |
this.state = { | |
name: '' | |
}; | |
this.set_name = this.set_name.bind(this); | |
} | |
set_name() { | |
this.setState({ | |
name: 'Mohammad' + Math.random() | |
}); | |
} | |
render() { | |
console.log('Render'); | |
return ( | |
<div> | |
<h1>{this.state.name}</h1> | |
<button onClick={this.set_name}>Click</button> | |
</div> | |
); | |
} | |
} | |
render( | |
<App/>, | |
document.getElementById('root') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment