vite-plugin-federation
vite-plugin-federation copied to clipboard
Remote module with shared react with react hooks
Versions
"@originjs/vite-plugin-federation": "^1.2.3",
"vite": "^4.3.9",
"@vitejs/plugin-react": "^4.0.0",
Reproduction
What is Expected?
To work great with the hook.
What is actually happening?
I get: Uncaught TypeError: Cannot read properties of null (reading 'useState')
Same code without the useState hook works great!
Any ideas how to fix? workaround? I think the opened PR is supposed to fix this issue? https://github.com/originjs/vite-plugin-federation/pull/450
Thanks community!
Facing same issue
@bw-kshitij-vengurlekar Did you solve it somehow?
I'm not at my computer right now. But I think the issue is you're not sharing react. I'll have to get back to me keyboard to confirm. If you go into source in the browser you should see federated react and that's the use state the remote should be using.
Hi same for me: As soon as I'm using hooks in Host or Remote its not working for v1.3.1 (using build versions and vite preview for host+remote)
Removing the hooks, it works just fine And it is even working fine for v1.2.1 with hooks
Same here