Skip to content

Instantly share code, notes, and snippets.

@Uzwername
Created August 27, 2020 21:17
Show Gist options
  • Save Uzwername/e35725f2dab4566a13ece7a299c9602f to your computer and use it in GitHub Desktop.
Save Uzwername/e35725f2dab4566a13ece7a299c9602f to your computer and use it in GitHub Desktop.
Functions vs. Components - App.js with description
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