Skip to content

Instantly share code, notes, and snippets.

@AZagatti
Last active May 20, 2020 19:15
Show Gist options
  • Save AZagatti/8bde72f91539797f740768eff0406e61 to your computer and use it in GitHub Desktop.
Save AZagatti/8bde72f91539797f740768eff0406e61 to your computer and use it in GitHub Desktop.
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