Skip to content

Instantly share code, notes, and snippets.

@cbrannen9a
Created January 18, 2019 10:03
Show Gist options
  • Save cbrannen9a/09293b5892a3b9d0fa2bcfc466ce9115 to your computer and use it in GitHub Desktop.
Save cbrannen9a/09293b5892a3b9d0fa2bcfc466ce9115 to your computer and use it in GitHub Desktop.
React hooks useState example
export const UseState = () => {
//Declare state value of count and setCount function to update
//set the initial value of count as 0
const [count, setCount] = useState(0);
//setCount function
return (
<div className='content'>
<h4>UseState</h4>
<p>You clicked {count} times</p>
<button
className='button'
onClick={() => setCount(count + 1)}>
Click me
</button>
</div>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment