Skip to content

Instantly share code, notes, and snippets.

@buglessir
Created April 2, 2019 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buglessir/f8bad7970d759edf33fecb77768b2191 to your computer and use it in GitHub Desktop.
Save buglessir/f8bad7970d759edf33fecb77768b2191 to your computer and use it in GitHub Desktop.
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