React · Middle · Question 52 of 75
Where should code that runs because the user clicked "Buy" go?
- ✓Correct answer: In the event handler, not in an effect reacting to state
- 2In a
useEffectthat watches aboughtflag - 3In the component body during render
Explanation
Effects are for synchronizing with external systems because the component is displayed. Logic caused by a specific interaction belongs to that interaction's handler.