Open FrancicoVerdu opened 7 months ago
you most likely forgot to add singletion: true to shared deps configuration of react. Also always add required version for react too, so that runtime has easier time understanding which version should be loaded.
It should be:
shared: {
'react': { singleton: true, requiredVersion: '^18.3.1' },
'react-dom': { singleton: true, requiredVersion: '^18.3.1' },
}
I am trying to use swr in my host component, but when I use ModuleFederationPlugin, I get an error “hooks can only be called inside of the body of a function component”. This only happens when I use remotes and not when I use exposes. I leave an example of App with SWR to replicate the error, it is not necessary to add the remote component to the App just add it to the remotes inside rsbuild.config.ts. I am using React, Typescript and Rsbuild.