-
-
Notifications
You must be signed in to change notification settings - Fork 730
Toast Container in module federation architecture #1163
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
Comments
Hi, I solved this issue by creating a global globalToast variable that all micro frontends (MFEs) can access. Ensure there's only one ToastContainer in the host app, and every remote app can trigger toasts without any issues. if (!window.globalToast) { This way, the ToastContainer remains in the shell app, and the toast() function can be accessed globally by all remote apps. |
Not working for me
But when inside a microfrontend imported using module federation I do
|
For me, putting this library into "shared" in module federation settings solved the problem. |
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I have a micro front end architecture with shell app and remote apps following webpack module federation approach.
I add ToastContainer to shell app but my remote apps seem to not see it. toast(..) just does nothing.
Looks like the container is unregistered once a remote app is mounted.
Shell is rendered this way
root.render( <Provider store={store}> <ToastContainer position='top-right' /> <Suspense fallback={<PageLoader withHeader={false} />}> <ThemeProvider theme={theme}> <CssBaseline /> <App /> </ThemeProvider> </Suspense> </Provider>, );
where App in its turn has Routes to remote apps.
So, in terms of DOM all the remote apps are nested under shell-root
Any remote app in its turn is rendered in its own root
const root = createRoot(mountPoint); // mountPoint, for example, is maintenance-mfe
root.render( <ThemeProvider theme={theme}> <Provider store={maintenanceStore}> <RouterProvider router={router} /> </Provider> </ThemeProvider>, );
The text was updated successfully, but these errors were encountered: