-
-
Notifications
You must be signed in to change notification settings - Fork 272
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
fix: prevent destroy/render the remote component every time rerendering from the host #3479
base: main
Are you sure you want to change the base?
Conversation
|
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
a2e87fe
to
5340af4
Compare
@@ -102,7 +102,7 @@ export function createRemoteComponent<T, E extends keyof T>( | |||
|
|||
return forwardRef<HTMLDivElement, ProviderParams & RawComponentType>( | |||
(props, ref) => { | |||
const LazyComponent = createLazyRemoteComponent(info); | |||
const LazyComponent = useMemo(() => createLazyRemoteComponent(info), []); |
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.
you probbably should pass info to the dependencies []
array of use memo, if you change the lazy remote then youd want memo to refresh most likely?
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.
Actually, we do not need to pass info
to the dependencies []
array. We shouldn't update these (loader, loading, fallback) from info
while using the createRemoteComponent
function, I expect they should be initialized only once. If we want to update LazyComponent
due to a state/prop change, simply updating props
and pass to LazyComponent
, as we did, is enough for our case.
5340af4
to
63d8393
Compare
Description
Implement memoization for
LazyComponent
every timecreateRemoteComponent
is called, so the remote component won't call the destroy/render method when the state changes from the host.Related Issue
#3478
Types of changes
Checklist