Code splitting: React.lazy() example is missing a Suspense wrapper
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 11.8k
- Forks
- 7.9k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 11
Description
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.
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the React.lazy section of the code-splitting guide at the linked URL and compare its example with the later Suspense example. Reproduce the behavior using the linked CodeSandbox, then update the documentation so the lazy-loading example is accurate and does not mislead readers about the required fallback UI.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100