Open nahimr opened 7 months ago
Try adding to package.json following: "resolutions": { "react": "18.3.1" },
Replace react version with yours
Hello nahimr, were you able to resolve this error?
I can fix this issue by adding these two dependencies in host and remote app-
"@mui/x-data-grid-premium": {
singleton: true,
eager: true,
requiredVersion: deps["@mui/x-data-grid-premium"],
},
"@emotion/styled": {
singleton: true,
eager: true,
requiredVersion: deps["@emotion/styled"],
},
Incase using ThemeProvider then wrap host app with ThemeProvider as well
I dont like it, but in a setup where both host and remote are Vite projects then adding "@emotion/styled" and "@mui/material" as shared in both host and remote fixed the problem for me: federation({ name: 'remote', // name of the fed group... filename: 'remoteEntry.js', // default file name
// Modules to expose
exposes: {
'./Remote': './src/Remote',
},
shared: ['react', 'react-dom', "@emotion/styled", "@mui/material"] // <--- these deps
}),
When host is Webpack and remote is Vite, removing the node_modules + package-lock, and changing the @mui/material version to be strictly 5.15.4 did the job. i.e., in package.json, update the dependency to this: "@mui/material": "5.15.4",
When calling
useTheme
hook from @mui/material, this throws an error.Shared dependencies
On host side :
On remote side :
Versions
Steps to reproduce
What is Expected?
It's expected to use correctly the hook
useContext
that its called byuseTheme
.What is actually happening?
It's missing shared
useContext
reference of React.Related to #595.