Last active
May 20, 2020 19:15
-
-
Save AZagatti/8bde72f91539797f740768eff0406e61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react"; | |
export default function useCount() { | |
const [count, setCount] = useState(0); | |
function increment() { | |
setCount(state => state + 1); | |
} | |
function decrement() { | |
setCount(state => state - 1); | |
} | |
return { count, increment, decrement }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment