Skip to content

Instantly share code, notes, and snippets.

@eldyvoon
Created December 17, 2019 10:10
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 eldyvoon/f646bb1203f7aa73efce12c940f64078 to your computer and use it in GitHub Desktop.
Save eldyvoon/f646bb1203f7aa73efce12c940f64078 to your computer and use it in GitHub Desktop.
import { useState } from "react";
const useCounter = initCount => {
const [count, setCount] = useState(initCount);
return [
count,
() => setCount(count => count + 1),
() => setCount(count => count - 1)
];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment