Skip to content

Instantly share code, notes, and snippets.

@techomoro
Created April 1, 2020 12: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 techomoro/ce3b139fb52341b201ef2d3f7e797533 to your computer and use it in GitHub Desktop.
Save techomoro/ce3b139fb52341b201ef2d3f7e797533 to your computer and use it in GitHub Desktop.
import React, { Component } from "react";
import Button from "./components/Button";
import "./assets/css/style.css";
export default class App extends Component {
constructor() {
super();
this.state = {
count: 0
};
}
incrementCount = () => {
this.setState({
count: this.state.count + 1
});
};
decrementCount = () => {
this.setState({
count: this.state.count - 1
});
};
render() {
let { count } = this.state;
return (
<div className="app">
<div>
<div class="count">
<h3>Count:</h3>
<h1>{count}</h1>
</div>
<div class="buttons">
<Button title={"-"} action={this.decrementCount} />
<Button title={"+"} action={this.incrementCount} />
</div>
</div>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment