Skip to content

Instantly share code, notes, and snippets.

@buglessir
Created April 2, 2019 11:18
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/41be29e13c26b7af0aa59e7338507730 to your computer and use it in GitHub Desktop.
Save buglessir/41be29e13c26b7af0aa59e7338507730 to your computer and use it in GitHub Desktop.
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