Created
August 27, 2020 21:17
-
-
Save Uzwername/e35725f2dab4566a13ece7a299c9602f to your computer and use it in GitHub Desktop.
Functions vs. Components - App.js with description
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
const App = () => { | |
const [total, setTotal] = useState(0); | |
const incrementTotal = () => setTotal((currentTotal) => currentTotal + 1); | |
const Description = () => ( | |
<p> | |
I like coding counters! | |
Sum of all counters is now {total} | |
</p> | |
); | |
return ( | |
<div className="App"> | |
<div> | |
<h4>Total Clicks: {total}</h4> | |
<Description /> | |
</div> | |
<div className="CountersContainer"> | |
<Counter onClick={incrementTotal} /> | |
<Counter onClick={incrementTotal} /> | |
<Counter onClick={incrementTotal} /> | |
</div> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment