Skip to content

Instantly share code, notes, and snippets.

@theham3d
Created October 31, 2018 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theham3d/f040d218c46a5961fb37b3ffc3aa896d to your computer and use it in GitHub Desktop.
Save theham3d/f040d218c46a5961fb37b3ffc3aa896d to your computer and use it in GitHub Desktop.
useStateExample
import React , { useState } from 'react';
const MyCounter = props => {
const [count, setCount] = useState(0);
//you can use useState as much as you want
return (
<div>
<h1>{count}</h1>
<button onClick={() => setCount(count + 1)}>Click me</button>
</div>
);
}
export default MyCounter;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment