Created
June 30, 2022 20:33
-
-
Save nemrosim/e92664ddc8ccfbfc2ae4b4d800484b8c to your computer and use it in GitHub Desktop.
This file contains 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 { 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