module-federation / module-federation-examples

Implementation examples of module federation , by the creators of module federation
https://module-federation.io/
MIT License
5.56k stars 1.74k forks source link

Exposed component cannot be wrapped with Redux provider when remote is consumed as dynamic remotes #4282

Open AshanPerera98 opened 2 days ago

AshanPerera98 commented 2 days ago

I have two react apps running on the following stack


When shell app tries to render the remote it gives the following errors in the console

Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app

AND

react.development.js:1650 Uncaught TypeError: Cannot read properties of null (reading 'useMemo')

When I remove the Provider and the Store config from the constructor it works fine.

This is the module-federation sample that I followed https://github.com/module-federation/module-federation-examples/blob/master/advanced-api/dynamic-remotes/app1/src/App.js

ScriptedAlchemy commented 21 hours ago

Have you shared React and Redux, etc. as a singleton?