developit / unistore

🌶 350b / 650b state container with component actions for Preact & React
https://npm.im/unistore
2.86k stars 139 forks source link

Multiple Stores Overwrite on last store #197

Open adminy opened 2 years ago

adminy commented 2 years ago

Rather than merging store with previous store I would like to have them separately. E.g.

const AuthStore = ({ children }) => <Provider store={pageStore}>{children}</Provider>
const PageStore = ({ children }) => <Provider store={authStore}>{children}</Provider>

render(
  <AuthStore>
    <PageStore>
       ...
    </PageStore>
  </AuthStore>
, document.body)

But currently when I try to use the stores in a component:

const A = connect('page', 'auth')(({ page, auth, children }) => (
     // page is defined but not auth
)

it seems like Page provider overwrites the Auth provider.