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.
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 aReact.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:
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.