-
Notifications
You must be signed in to change notification settings - Fork 47.8k
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: nested Suspense with lazy children permanently shows fallback #32313
Comments
Does this work if |
@eps1lon thanks for the quick response. Moving the LazyChild creation out of render no longer triggers this issue. However, I am not aware of it being "against the rules" to use // 🔴 Bad: This will cause all state to be reset on re-renders
const MarkdownPreview = lazy(() => import('./MarkdownPreview.js')); However, one would think that wrapping with Anyway, it still seems like a bug that this puts the Suspense into a broken state. From the app's perspective, the async function has finished executing and there is no state in the app code itself. If this is truly not allowed, I would expect an error message rather than a partially-working/partially-broken app. As for your other statement,
function lazy<T extends ComponentType<any>>(
load: () => Promise<{ default: T }>,
): LazyExoticComponent<T>; |
You don't need to specify an |
@eps1lon Thanks, so to confirm, are you saying the usage of |
React version: both 18.3.1 and 19.0.0
When creating a
lazy
component inuseMemo
, and rendering inside nested Suspense, the suspense continues to render itsfallback
forever and never mounts the component – even after the component has had time to load.This is reproducible with both 18.3.1 and 19.0.0.
May be related to #30582?
The current behavior
When rendering Suspense in a parent and the lazy component in a child, the lazy component never loads (line 2). However, when the child component additionally wraps its own Suspense, the loading succeeds (lines 1 & 3).
The expected behavior
All lazy components should render
Steps To Reproduce
Link to code example: https://stackblitz.com/edit/vitejs-vite-yafxnrot?file=src%2FApp.tsx
The text was updated successfully, but these errors were encountered: