DEV Community

Discussion on: Master the art of React.useEffect

Collapse
larsejaas profile image
Lars Ejaas • Edited on

Great article! Remember that you can also use the hook: useLayoutEffect as an alternative. This is almost identical, but the logic will run just BEFORE the screen painting phase. I sometimes use it with animations.

Collapse
alarid profile image
Yohann Legrand Author

Thanks! I wouldn't recommend using useLayoutEffect for anything else than DOM updates though. In fact, I only use it if I need to mutate the DOM in an observable way to the user and/or to perform measurements. I'll probably write about this hook in the future, so stay tuned :)