Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.0.0-alpha.0] Can't provide custom redux store #3445

Closed
johannesfritsch opened this issue Jul 23, 2019 · 1 comment
Closed

[3.0.0-alpha.0] Can't provide custom redux store #3445

johannesfritsch opened this issue Jul 23, 2019 · 1 comment
Labels

Comments

@johannesfritsch
Copy link

johannesfritsch commented Jul 23, 2019

What you were expecting:
I can provide a store through react-redux' Provider and am not forced to provide a dataProvider on the <Admin> component.

What happened instead:
When I skip the dataProvider I get the error "Missing dataProvider prop.". If I pass the dataProvider too (which I don't need according to the docs and a quick look at CoreAdmin.tsx) multiple stores are created: The one I wrapped <Admin> in and another one that created.

Steps to reproduce:
Wrap <Admin> inside a <Provider> with a store. We simply followed these steps: https://github.com/marmelab/react-admin/blob/next/docs/CustomApp.md

Related code:

<Provider store={this.store}>
        <Admin layout={Layout} theme={Theme} title="Mall-X" history={history} authProvider={authProvider} loginPage={Login}>
          ...
        </Admin>
      </Provider>

Other information:
I had a look into CoreAdmin.tsx. I think you have to provide the CoreAdmin.contextType there in order to consume the context.store. As the context is empty during initialization the member variable this.reduxIsAlreadyInitialized is never set to true. That's why render wraps the renderCore into another <Provider> with a store from local createAdminStore(...).

Environment

  • React-admin version: 3.0.0-alpha.0
  • Last version that did not exhibit the issue (if applicable): Latest v2 afaik
  • React version: 16.8.1
  • Browser: Latest Chrome
  • Stack trace (in case of a JS error): No stack trace
djhi added a commit that referenced this issue Aug 2, 2019
@djhi
Copy link
Collaborator

djhi commented Aug 2, 2019

Thanks for reporting this 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants