useLayoutEffect. The signature is identical to useEffect , but it fires synchronously after all DOM mutations. Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside useLayoutEffect will be flushed synchronously, before the browser has a chance to paint.
useLayoutEffect works exactly the same as useEffect
useLayoutEffect runs synchronously while useEffect runs asynchronously
useLayoutEffect runs after the code mutation
useLayoutEffect make changes before the browser paints the DOM
Just remember useLayoutEffect is identical to useEffect but runs synchronously !!