Skip to content
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

Merged
merged 6 commits into from Apr 19, 2024

Conversation

arunvishnun
Copy link
Contributor

@arunvishnun arunvishnun commented Apr 17, 2024

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 leverage root.unmount() for managing component lifecycles more effectively.

@arunvishnun arunvishnun marked this pull request as ready for review April 17, 2024 19:22
@arunvishnun arunvishnun requested a review from a team as a code owner April 17, 2024 19:22
});

expect(element.innerHTML).to.equal("");
});
Copy link
Member

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

Copy link
Contributor Author

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)

Copy link
Contributor Author

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.

Copy link
Member

@kylejeske kylejeske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay 👍

Copy link
Contributor

@shubham2811 shubham2811 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arunvishnun arunvishnun merged commit 809757d into electrode-io:master Apr 19, 2024
3 checks passed
@arunvishnun arunvishnun mentioned this pull request Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants