Created
April 1, 2020 12:18
-
-
Save techomoro/ce3b139fb52341b201ef2d3f7e797533 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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