Skip to content

Code splitting: React.lazy() example is missing a Suspense wrapper #1810

Description

@manuelbieh

I'm not quite sure if this is intentional to only demonstrate how React.lazy() is used, if the API how lazy() works was changed after that part of the docs have been written already, if I am using it incorrectly or if it is actually wrong but in the example but in the code splitting guide you're using a component wrapped in a React.lazy() and do not wrap it in a <Suspense>:

https://reactjs.org/docs/code-splitting.html#reactlazy

When I do that I get an error message:

A React component suspended while rendering, but no fallback UI was specified.

Source

Two paragraphs later Suspense is introduced and then a working example is shown where the lazy-loaded component is correctly wrapped in <Suspense> but I don't know if it is a good idea to have a non-functioning example in the documentation in the first place as it might be misleading.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions