React Developer interview question · Most asked
When do you NOT need `useEffect`?
Summary
You don't need effects to derive data from props/state (compute during render), to handle user events (do it in event handlers), to reset state on prop change (use key), to chain state updates, or to notify parents (call callbacks in handlers).
Longer Answer
Effects are for synchronizing with external systems (subscriptions, network, DOM APIs). Unnecessary effects cause extra renders and bugs.
Key Points
- Derive during render
- Use event handlers for events
keyto reset state- Effects only for external sync
More most-asked React Developer questions
- Explain React concept: keys in lists.
- Explain React concept: unidirectional data flow.
- Explain React concept: controlled vs uncontrolled inputs.
- Explain React concept: state.
- Explain React concept: lifting state up.
- What does `useState` do and when should you use it?
- What does `useEffect` do and when should you use it?
- What does `useContext` do and when should you use it?