useLayoutEffect vs useEffect

정은경·2022년 8월 31일
0

👸 Front-End Queen

목록 보기
235/271

The React useLayouEffect hook is written the same way as useEffect, and almost behaves the same way.
One of the key differences is that it gets executed right after a React component render lifecycle, and before useEffect gets triggered.

useLayoutEffect is identical to useEffect, but it’s major key difference is that it gets triggered synchronously after all DOM mutation.
You only want to use this hook when you need to do any DOM changes directly.

Reference

profile
#의식의흐름 #순간순간 #생각의스냅샷

0개의 댓글