I'd like to know how to use custom hook correctly #246
-
I'd like to know how to use custom hook correctly |
Beta Was this translation helpful? Give feedback.
Answered by
whitehorse21
Jun 7, 2023
Replies: 1 comment 2 replies
-
How to define custom hook? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is one sample
import { useEffect, useState } from 'react';
export function useIsMounted() {
const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);
return mounted;
}