πŸ“Š React Js
Q. How do you ensure a component only mounts once with a side-effect?
  • (A) Use useEffect without dependencies
  • (B) Use useEffect with an empty array
  • (C) Use componentDidUpdate
  • (D) Use useState
πŸ’¬ Discuss
βœ… Correct Answer: (B) Use useEffect with an empty array

Explanation: Using `useEffect(() => {}, [])` ensures the side-effect runs only once.

Explanation by: Mr. Dubey
Using `useEffect(() => {}, [])` ensures the side-effect runs only once.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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