Which React Hook pattern is functionally equivalent to the componentDidMount lifecycle...
Nopal Securities technical mcq question, verified with a worked answer. Free to practise - no sign-up.
Which React Hook pattern is functionally equivalent to the componentDidMount lifecycle method in class components?
Show answer & explanation
Answer: A. useEffect with an empty dependency array []
useEffect with [] runs exactly once after the initial render, mirroring componentDidMount lifecycle behavior.
Step-by-step Derivation:
Step 1: In React functional components, useEffect(() => {}, []) runs only on mount.