Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ClickCounter extends React.Component {
- constructor(props) {
- super(props);
- this.state = {count: 0};
- this.onClick = () => {
- this.setState((state, props) => {
- return {count: state.count + 1};
- });
- }
- }
- render() {
- return [
- <button key="1" onClick={this.onClick}>Update name</button>,
- <span key="2">{this.state.count}</span>
- ]
- }
- componentDidUpdate() {}
- getSnapshotBeforeUpdate() { return null }
- }
Add Comment
Please, Sign In to add comment