The browser crashes when use React.lazy return Promise.resolve(undefined)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 251k
- Forks
- 51.4k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 53
Description
Do you want to request a feature or report a bug?
bug
What is the current behavior?
The browser crashes
const Loading = () => <div>loading...</div>;
const Component = lazy(() => Promise.resolve(undefined));
function App() {
return (
<div className="App">
<Suspense fallback={<Loading />}>
<Component />
</Suspense>
</div>
);
}
I can't provide an example of CodeSandbox, which would cause the browser to crash
What is the expected behavior?
throw Error
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
react@16.8.3
react-dom@16.8.3
chrome 72.0.3626.119
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
Start by reproducing the React.lazy example with React 16.8.3 and inspect the lazy-loading entry point involved when the loader resolves to undefined. The fix is complete when this invalid result throws an Error instead of crashing the browser, with a regression test covering the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100