-
Notifications
You must be signed in to change notification settings - Fork 300
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
feat: expose subapp root to provide better lifecycle control for applications #2008
Conversation
}); | ||
|
||
expect(element.innerHTML).to.equal(""); | ||
}); |
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.
Does it make sense to add a use case where the server content is mismatched from the client's content?
https://react.dev/reference/react-dom/client/hydrateRoot#caveats
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.
@kylejeske Hydration itself is already implemented, so probably that should be on a different PR.
This specifically was to test the enhancement to expose root and then app could do some lifecycle management. (line 114)
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.
Also, if there is a mismatch from server content, react itself would show warning and application need to fix that first before they use root for unmount IMO.
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.
okay 👍
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.
LGTM
Summary
In React 18, unmountComponentAtNode was replaced by root.unmount().
Reference: https://react.dev/reference/react-dom/unmountComponentAtNode#unmountcomponentatnode
To accommodate this update, this PR modifies the implementation to expose the
root
object. By doing so, it enables applications built with SubappV1 to leverageroot.unmount()
for managing component lifecycles more effectively.