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

Can't include in app with connected-react-router v5 #2549

Closed
AleBlondin opened this issue Nov 20, 2018 · 12 comments
Closed

Can't include in app with connected-react-router v5 #2549

AleBlondin opened this issue Nov 20, 2018 · 12 comments

Comments

@AleBlondin
Copy link
Contributor

Please do not submit support requests or "How to" questions here. For that, go to StackOverflow.

What you were expecting:
I include React-admin in my app. I expect it to work, it crashes.

Steps to reproduce:
Have an App that uses connected-react-router, especially v5. The routing state in redux is stored under a key named "router" and cannot be changed.
However in react-admin the key is named "routing" and cannot be changed either.
For information react-router-redux (used by react-admin) is deprecated, the new library to use is connected-react-router

Suggested change:
I suggest changing the routing store key name in react-admin from "routing" to "router". I believe it involves changing these only 3 files:

  • packages/ra-core/src/sideEffect/auth.js
  • packages/ra-core/src/reducer/index.js
  • packages/ra-ui-materialui/src/layout/Menu.js

And documentation:

  • docs/CustomApp.md
  • docs/Admin.md

I would glady open a PR.

Other information:

Environment

  • React-admin version: 4.2.4
  • Last version that did not exhibit the issue (if applicable): /
  • React version: 16.6.0
  • Browser: Chrome
  • Stack trace (in case of a JS error):
    image
@fzaninotto
Copy link
Member

Duplicate of #1999.

@AleBlondin
Copy link
Contributor Author

@fzaninotto I don't agree it is a duplicate. I am not saying that react-router-redux is deprecated, but that react-admin is not compatible with connected-react-router.
I believe it is possible to make the 2 compatible with each other without any lib upgrade.

@fzaninotto
Copy link
Member

fzaninotto commented Nov 20, 2018

Sorry, I must have misunderstood something. You're saying that connected-react-router doesn't allow to change the routing key in the state, so I don't understand how your proposed change can be backwards compatible.

@AleBlondin
Copy link
Contributor Author

Indeed, connected-react-router doesn't allow to change the routing key in the state, but redux-react-router does. I suggest changing the routing key in react-admin while it still uses redux-react-router.

I hope I made myself clearer 😃

@fzaninotto
Copy link
Member

Yes, now I understand, thanks. I'd gladly accept a PR to change the routing key in the react-admin state. Please open it against next, because even if this key isn't a public API, I prefer that people using it have their application broken by upgrading to a minor rather than a bugfix.

@fzaninotto fzaninotto reopened this Nov 21, 2018
@fzaninotto
Copy link
Member

Fixed by #2551

@fzaninotto
Copy link
Member

Sorry, wrong issue.

@fzaninotto fzaninotto reopened this Nov 21, 2018
@djhi
Copy link
Contributor

djhi commented Nov 21, 2018

Make sure we don't use any selectors from redux-react-router. I think they can't be configured to use another key than routing. At least I remember having the issue

@AleBlondin
Copy link
Contributor Author

The redux-react-router docs say here that you can specify a custom routing state selector if needed.
However, it is only if you use the syncHistoryWithStore method. It seems it isn't needed since v5 alpha of redux-react-router (the version used by react-admin). Plus this method is not used in react-admin.

I created the PR, the tests pass. Do you think I ought to write documentation about this change ? And where would I write it ?

@fzaninotto
Copy link
Member

No need for more documentation, we'll mention it in the changelog.

@AleBlondin
Copy link
Contributor Author

Ok thanks. I think my PR is ready, it is here

@fzaninotto
Copy link
Member

Fixed by #2553

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

No branches or pull requests

3 participants