React · Junior · Question 36 of 75
What does React.lazy need in order to work?
- ✓Correct answer: Wrap it (or an ancestor) in
<Suspense fallback> - 2Call
lazyinsideuseEffectafter mounting - 3Add an
asyncattribute to the lazy component
Explanation
While the code loads, the component "suspends" and the nearest <Suspense> shows its fallback. Declare lazy at module level, not inside a component - otherwise every render creates a new component and loses state. The module must have a default export.