Q. What is the difference between useEffect and useLayoutEffect?

  • (A) useLayoutEffect fires synchronously after all DOM mutations, useEffect fires asynchronously after paint
  • (B) useEffect is only for class components
  • (C) useLayoutEffect is deprecated
  • (D) There is no difference
πŸ’¬ Discuss
βœ… Correct Answer: (A) useLayoutEffect fires synchronously after all DOM mutations, useEffect fires asynchronously after paint
Explanation: useLayoutEffect runs before the browser paints, useful for measuring layout.
Explanation by: Mr. Dubey
useLayoutEffect runs before the browser paints, useful for measuring layout.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
70
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
87%
Success Rate