Skip to content

Instantly share code, notes, and snippets.

@nemrosim
Created June 30, 2022 20:33
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 nemrosim/e92664ddc8ccfbfc2ae4b4d800484b8c to your computer and use it in GitHub Desktop.
Save nemrosim/e92664ddc8ccfbfc2ae4b4d800484b8c to your computer and use it in GitHub Desktop.
import { useEffect, useState } from 'react';
export const useSimplestHook = () => {
const [isTrue, setIsTrue] = useState(false);
useEffect(() => {
const id = setTimeout(() => {
setIsTrue(true);
}, 1000);
return () => {
clearTimeout(id);
};
}, []);
const toggle = () => {
setIsTrue(!isTrue);
};
return { isTrue, toggle };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment