Publications de Gauthier FIORENTINO

Archi & techno

Why you should use useLayoutEffect when tinkering with focus

In this article, we will try to understand what useLayoutEffect is. I will attempt to demonstrate that you probably should: - Use regular effects with useEffect whenever possible to streamline the user experience. - Use regular effects to run asynchronous tasks as they will not be awaited anyway. - Use layout effects with useLayoutEffect whenever you need to run effects before the visual is painted to modify it. - Use layout effects when you need to handle the focus programatically, to avoid screen flickering. So let’s get into it!

Lire la suite