Created
April 2, 2019 11:17
-
-
Save buglessir/69a950d4c51147ce0a9f9a5acd5f44b0 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' | |
}); | |
} | |
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