My FeedDiscussionsHashnode Enterprise
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
31 followers·27 articles
Chinaza Egbo
Victory Asokomeh
useLayoutEffect Similar to useEffect but fires synchronously after all DOM mutations(react docs). It can be used to make changes before the browser has a chance to paint. I can think of two instances where it can be applied; Dynamically setting document title useLayoutEffect(() => { document.title = "Profile"; }, []); The page title is set before the browser has a chance to paint. Verifying user token when your root component mounts (app) const { handleLogout } = useAuth(); useLayoutEffect(() => { checkTokenValidity(handleLogout); }, [handleLogout]);

You've reached the end! 👋