Created
April 2, 2019 11:16
-
-
Save buglessir/f8bad7970d759edf33fecb77768b2191 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, { Component } from 'react'; | |
import { render } from 'react-dom'; | |
class App extends Component { | |
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