-
Notifications
You must be signed in to change notification settings - Fork 220
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
Zustand in remote app causes issues #478
Comments
I have cloned your repo to check it out, and I will give the following workaround:
If you want a reference on how to share state between host and remote using zustand, you can refer to my repo |
@nguyenbatranvan thanks for the response! |
have you tried downgrade vite-plugin-federation to v1.1.14? |
Same issue happens with |
Hey all, is there a recent solution or a plan for resolving this? The version 1.1.14 is now already rather old The workaround of adding the package also to the host works, but is still just a workaround imho |
I still got error even downgrading to 1.1.14 (for host and remote) |
Versions
Reproduction
There is an issue if you install zustand as a state manager in a remote app.
I did some research and noticed that zustand has use-sync-external-store as a dependency (here), which is bundled in cjs and in its turn imports react as a commonjs module:
require("react")
.It causes two issues:
import { r as reactExports, g as getDefaultExportFromCjs } from './__federation_shared_react.js';
However, this
reactExports
is undefined which results in an error:Error: Cannot read properties of undefined (useRef)
.Here is a github repo that you can clone and reproduce the issue there.
Extra import in the remote app output:
![Screenshot 2023-08-10 at 14 44 58](https://private-user-images.githubusercontent.com/65358012/259733882-6462bce5-10ea-43b8-9cb6-d66501191ca8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyMjMwMjUsIm5iZiI6MTcxOTIyMjcyNSwicGF0aCI6Ii82NTM1ODAxMi8yNTk3MzM4ODItNjQ2MmJjZTUtMTBlYS00M2I4LTljYjYtZDY2NTAxMTkxY2E4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI0VDA5NTIwNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWMxN2E3YzExNWU3M2JlNzQ4Nzg2YWI1NjA1MTA4YTNiYWU1MTZiNDA2NWY3MDM0YjhhMmE3MDZlZDk3NjI1ZTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.TYFdnjzPb6ON9GVA0o4Wn4SUPMJy_O6dK73Lj_gFVEc)
Commonjs import of "react" in "use-sync-external-store" package:
![Screenshot 2023-08-10 at 15 01 57](https://private-user-images.githubusercontent.com/65358012/259734006-6c529f3e-6ccc-4330-bdff-bde407c7cfd6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyMjMwMjUsIm5iZiI6MTcxOTIyMjcyNSwicGF0aCI6Ii82NTM1ODAxMi8yNTk3MzQwMDYtNmM1MjlmM2UtNmNjYy00MzMwLWJkZmYtYmRlNDA3YzdjZmQ2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI0VDA5NTIwNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJmOTk2YWJkM2M1Y2JmZTI0NmM4NWI5NWZlY2YxZjY5ZDU4NzZjYWJlZmY0NGYyMzhhNmJlMjJkYjMzMWEyOWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.YQucRiFpq8gXOjGpRXfsj2dRC7AunI--5VPKHNBx9vE)
Steps to reproduce
pnpm install
in the root of the project;pnpm build && pnpm serve
;What is Expected?
The text was updated successfully, but these errors were encountered: