Skip to content

Instantly share code, notes, and snippets.

@jogilvyt
Created January 19, 2021 15:20
Show Gist options
  • Save jogilvyt/1817ddba635d485b8cda50ecbedd9790 to your computer and use it in GitHub Desktop.
Save jogilvyt/1817ddba635d485b8cda50ecbedd9790 to your computer and use it in GitHub Desktop.
Simple React counter application
import { useState } from "react";
function App() {
const [count, setCount] = useState(0);
return (
<div>
<h1>Counter</h1>
<p>Number: {count}</p>
<button onClick={() => setCount(count - 1)}>-1</button>
<button onClick={() => setCount(count + 1)}>+1</button>
</div>
);
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment