originjs / vite-plugin-federation

Module Federation for vite & rollup
Other
2.29k stars 236 forks source link

Remote module with shared react with react hooks #462

Open yuvalbne opened 1 year ago

yuvalbne commented 1 year ago

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!

bw-kshitij-vengurlekar commented 1 year ago

Facing same issue

yuvalbne commented 1 year ago

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

swalker326 commented 1 year ago

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.

pscl4 commented 1 year ago

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

billdwhite commented 1 year ago

Same here