Description
Do you want to request a feature or report a bug?
It can be seen as a feature or a bug, depending on angle. Let's say it's an enhancement to how lazy
works.
What is the current behavior?
When using React.lazy
, if the given promise rejects while trying to asynchronously load a component, it's no longer possible to retry loading the component chunk because lazy
internally caches the promise rejection.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
This does not seem to work great in CodeSandbox because it's using service workers, which get in the way when simulating offline mode, yet this small app illustrates the issue: https://codesandbox.io/s/v8921j642l
What is the expected behavior?
A promise rejection should not be cached by lazy
and another attempt to render the component should call the function again, giving it the chance to return a new promise.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
AFAIK all version of React that include lazy
.