Sign in
Log inSign up
react-router
react-router
#react-router-cinhn7r71003oxe534326vsqz
31 followers27 articles
Popular this week 馃敟
Chinaza Egbo
Victory Asokomeh
Usman Sabuwala
Hope Philip
Victory Asokomeh and 3 others are discussing this4 people are discussing this
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]);
3
Discuss

80 likes

2.2K reads

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]);
3

You've reached the end! 馃憢