vite-plugin-federation icon indicating copy to clipboard operation
vite-plugin-federation copied to clipboard

Remote module with shared react with react hooks

Open yuvalbne opened this issue 1 year ago • 5 comments

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!

yuvalbne avatar Jul 16 '23 16:07 yuvalbne

Facing same issue

bw-kshitij-vengurlekar avatar Aug 10 '23 04:08 bw-kshitij-vengurlekar

@bw-kshitij-vengurlekar Did you solve it somehow?

yuvalbne avatar Aug 20 '23 14:08 yuvalbne

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.

swalker326 avatar Aug 20 '23 19:08 swalker326

Bildschirmfoto 2023-09-15 um 13 22 49

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

pscl4 avatar Sep 15 '23 11:09 pscl4

Same here

billdwhite avatar Sep 15 '23 21:09 billdwhite