Skip to content

Instantly share code, notes, and snippets.

@shubich
Created January 14, 2018 22:03
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 shubich/22d08c5e54a5509cc8a8ff0d02705725 to your computer and use it in GitHub Desktop.
Save shubich/22d08c5e54a5509cc8a8ff0d02705725 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import { render } from 'react-dom';
import './style.css';
class App extends Component {
constructor() {
super();
this.state = {
count: 0,
};
}
inc = () => {
this.setState({
count: this.state.count + 1,
})
}
dec = () => {
this.setState({
count: this.state.count - 1,
})
}
render() {
return (
<div>
<div>{this.state.count}</div>
<button onClick={this.inc}>+</button>
<button onClick={this.dec}>-</button>
</div>
);
}
}
render(<App />, document.getElementById('root'));
@shubich
Copy link
Author

shubich commented Jan 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment