Skip to content

Instantly share code, notes, and snippets.

@chentsulin
Created November 5, 2018 15:26
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 chentsulin/a045c49434a88f7974c72eabed3157d9 to your computer and use it in GitHub Desktop.
Save chentsulin/a045c49434a88f7974c72eabed3157d9 to your computer and use it in GitHub Desktop.
counter hooks
const Counter = ({ defaultValue }) => {
const [count, setCount] = useState(defaultValue);
const handlePlusOne = () => {
setCount(count + 1);
}
return (
<>
<div>{count}</div>
<button onClick={handlePlusOne}>+</button>
</>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment