Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.