Skip to content

Instantly share code, notes, and snippets.

@rajeshpillai
Last active October 28, 2019 10:18
Show Gist options
  • Save rajeshpillai/3c3d7515cd226d5eb24c529c7f404693 to your computer and use it in GitHub Desktop.
Save rajeshpillai/3c3d7515cd226d5eb24c529c7f404693 to your computer and use it in GitHub Desktop.
useState - Example 1 - Simple state value
const {useState, useEffect} = React;
function Counter() {
const [counter, setCounter] = useState(0);
return (
<div className="content">
<h1 className="count">{counter}</h1>
</div>
);
}
const root=document.querySelector("#root");
ReactDOM.render(<Counter/>, root);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment