cerebral / overmind

Overmind - Frictionless state management
https://overmindjs.org
MIT License
1.58k stars 95 forks source link

[BUG] `overmind-react` - multiple overmind named instances #571

Open nkint opened 1 year ago

nkint commented 1 year ago

Hi! Thanks for the great library.

The documentations says here:

If you have multiple instances of Overmind on the same page you can name your app to differentiate them

But it's not clear to me how to correctly achieve this.

I want two separate states, and I created for each one of them a state/actions/config + a createOvermind method+ React hooks + a Provider. Only one of them is correctly read by the component that needs data from both overmind instances. Here there is a dumb example to reproduce the problem: https://codesandbox.io/s/overmind-multiple-named-instances-forked-i5biot?file=/src/index.tsx

I'm sure I'm doing it wrong but documentations lacks or there is a bug. I understand that I can use namespace but it doesn't fit my case.

nkint commented 1 year ago

I think that the problem relies in overmind-react and in how react context works.

This can be seen as a related problem: https://github.com/cerebral/overmind/issues/477