-
-
Notifications
You must be signed in to change notification settings - Fork 361
Description
Describe the bug
I set sandbox: false
under the main application of micro frontends, and then I have two sub-applications. In application A, I create instances and load remotely at runtime. When I first open the page, it displays normally in application A, but after switching to application B, an error occurs. Refreshing the page will make it work normally again, but switching from B back to A will still result in an error: Error: Invalid hook call. Hooks can only be called inside of the body of a function component.
I suspect it's because some fields set on the window property after createInstance are not destroyed in time when switching applications, causing application B to use snapshots or caches from application A. So I would like to ask if there is a way to promptly clear some caches generated by the runtime when the sub-application is unmounted?
Reproduction
Used Package Manager
yarn
System Info
System:
OS: macOS 15.5
CPU: (10) arm64 Apple M2 Pro
Memory: 170.91 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 16.20.1 - ~/.nvm/versions/node/v16.20.1/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v16.20.1/bin/yarn
npm: 8.19.4 - ~/.nvm/versions/node/v16.20.1/bin/npm
bun: 0.6.13 - ~/.bun/bin/bun
Browsers:
Safari: 18.5
Validations
- Read the docs.
- Read the common issues list.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Module federation issue and not a framework-specific issue.
- The provided reproduction is a minimal reproducible example of the bug.