We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useDepEffect
Runs a useEffect only when the dependency array changes and not on initial mount. (see related stackoverflow discussion)
useEffect
Instead of manually using a ref to know when the component mounted:
ref
const isMountedRef = useRef(); useEffect(() => { if (isMountedRef.current) document.title = `You clicked ${count} times`; isMountedRef = true; }, [count]);
Use the custom hook (much shorter):
useDepEffect(() => { document.title = `You clicked ${count} times`; }, [count]); // Only re-run the effect if count changes
The text was updated successfully, but these errors were encountered:
No branches or pull requests
useDepEffect
(use dependency effect)Runs a
useEffect
only when the dependency array changes and not on initial mount.(see related stackoverflow discussion)
Instead of manually using a
ref
to know when the component mounted:Use the custom hook (much shorter):
The text was updated successfully, but these errors were encountered: