-
Notifications
You must be signed in to change notification settings - Fork 46.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: React fails to log invariant 306 message when lazy() resolves to a Fragment
#26910
Comments
Hello, I think the issue you're encountering is related to using lazy with a dynamically resolved promise that resolves to { default: Fragment }. However, lazy expects the resolved value to be a class or function component, not an object. |
Firstly The same issue happens if you default export Secondly, the expected behaviour is to log an appropriate error from React. Instead it's failing to do so and throwing a random exception. Whether a lazily loaded Fragment should work is besides the point, that can be discussed in a separate issue. This bug is about the incorrect error message being displayed. |
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment! |
Still an issue on latest canary. |
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment! |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you! |
This still exists on latest canary. |
React version: 18.2.0
Steps To Reproduce
const LazyFragment = lazy(() => Promise.resolve({ default: Fragment }));
Link to code example:
https://github.com/tom-sherman/react-lazy-fragment-bug
The current behavior
It throws an error:
The expected behavior
It should throw an error related to invariant 306 eg.
The text was updated successfully, but these errors were encountered: