Skip to content

Instantly share code, notes, and snippets.

@myogeshchavan97
Last active April 4, 2021 17:01
Show Gist options
  • Save myogeshchavan97/46ff174c00efa93b51d57252fbfc6964 to your computer and use it in GitHub Desktop.
Save myogeshchavan97/46ff174c00efa93b51d57252fbfc6964 to your computer and use it in GitHub Desktop.
Hooks Based Counter Example
import React, { useState } from "react";
import ReactDOM from "react-dom";
const App = () => {
const [counter, setCounter] = useState(0);
return (
<div>
<div>
<p>Counter value is: {counter} </p>
<button onClick={() => setCounter(counter + 1)}>Increment</button>
</div>
</div>
);
};
ReactDOM.render(<App />, document.getElementById("root"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment