React · Junior · Question 36 of 75

What does React.lazy need in order to work?

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.

Further reading

Problem with a question

React · Junior · question 36

Test yourself

Take the React · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz