-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Test case for stack overflow in ReactFizzServer #25971
Conversation
function createNestedComponent(depth: number) { | ||
if (depth <= 0) { | ||
return function Leaf() { | ||
return <AsyncText text="Shell" />; | ||
}; | ||
} | ||
const NextComponent = createNestedComponent(depth - 1); | ||
function Component() { | ||
return <NextComponent />; | ||
} | ||
return Component; | ||
} | ||
const NestedComponent = createNestedComponent(1500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just make this a single component. Your current implementation returns a different instance on every re-render even for the same depth which is maybe not ideal.
function createNestedComponent(depth: number) { | |
if (depth <= 0) { | |
return function Leaf() { | |
return <AsyncText text="Shell" />; | |
}; | |
} | |
const NextComponent = createNestedComponent(depth - 1); | |
function Component() { | |
return <NextComponent />; | |
} | |
return Component; | |
} | |
const NestedComponent = createNestedComponent(1500); | |
function NestedComponent({depth}: {depth: number}) { | |
if (depth <= 0) { | |
return null; | |
} | |
return <NestedComponent depth={depth - 1} />; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch!
SSR currently stack overflows when the component tree is extremely large DiffTrain build for [fb324fa](fb324fa) [View git log for this commit](https://github.com/facebook/react/commits/fb324faf8a3da08212bcc5ea9e3a084dbfa80dad)
No description provided.