webpack module federation "could not find react-redux context value; please ensure the component is wrapped in a <Provider"

26 views Asked by At

i start microfrontend on host and get this. another microfront without redux is working, but this with him is down. its ONLY on host. so microfront is work on self, but down in host.

i using react router for webpack federation react 18.2.0 react-redux 9.1.0 reduxtoolkit: 2.2.1

import shopRoutes from 'shop/Router' import adminRoutes from 'admin/Router' export const router = createBrowserRouter([ { path: '/', element: <App />, children: [ ...shopRoutes, ...adminRoutes ] } ])

i found on forum this resolve: add to new webpack.container.ModuleFederationPlugin option shared: 'react-dom': { eager: true, requiredVersion: packageJson.dependencies['react-dom'] } but not working. anyone knows how fix this?

1

There are 1 answers

0
Alexander On

resolve:you need to wrap the root component of the paths in which you have an <Outlet /> in <Provider /> (for me it was an <App/> component, then when you send Routes via module federation, you already have a redux context.