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

require("history") console warnings #3138

Closed
handreistoicescu opened this issue Apr 18, 2019 · 17 comments · Fixed by #3144
Closed

require("history") console warnings #3138

handreistoicescu opened this issue Apr 18, 2019 · 17 comments · Fixed by #3144
Assignees
Labels

Comments

@handreistoicescu
Copy link

Hi! I'm using react-admin version 2.8.5, and I'm getting these warnings in the console. What could be wrong? I did a yarn upgrade also, and the warnings are still there.

Warning: Please use require("history").createBrowserHistoryinstead ofrequire("history/createBrowserHistory"). Support for the latter will be removed in the next major release.

Warning: Please use require("history").createHashHistoryinstead ofrequire("history/createHashHistory"). Support for the latter will be removed in the next major release.

Warning: Please use require("history").createMemoryHistoryinstead ofrequire("history/createMemoryHistory"). Support for the latter will be removed in the next major release.

Warning: Please use require("history").PathUtilsinstead ofrequire("history/PathUtils"). Support for the latter will be removed in the next major release.

@fzaninotto
Copy link
Member

The core has been fixed fir these warnings (originating from an update in the history dependency) in #3085. It's likely that you have an instance of these calls in your own code.

So I'm closing this as we can't reproduce the problem.

In the future, please use the issue template and give us a way to reproduce the bug.

@handreistoicescu
Copy link
Author

I lost a whole day trying to NOT reproduce the problem in different environments. I'm really curious which is the environment that you used, @fzaninotto

@fzaninotto
Copy link
Member

Well, if you do provide a way to reproduce the bug, it helps.

I'm running the simple demo locally and I have no error. But I saw that the error occurs in the react-admin CodeSandbox (that you should have linked form the issue template), so I'm reopening this issue.

@fvieira
Copy link

fvieira commented Apr 18, 2019

This seems to be caused by the react-router-dom dependency of ra-core which is on version 4.2.2 and has been fixed since version 4.3.0-rc.1.

This is the commit that fixed it:
remix-run/react-router@a3e6fac#diff-03323cab9211ecbb380f296cabff2285

@RandalTeng
Copy link

RandalTeng commented Apr 19, 2019

This seems to be caused by the react-router-dom dependency of ra-core which is on version 4.2.2 and has been fixed since version 4.3.0-rc.1.

This is the commit that fixed it:
ReactTraining/react-router@a3e6fac#diff-03323cab9211ecbb380f296cabff2285

About the react-router, I have upgrade to version 5.0.0, but the warnings is still there. I'm not really sure that this bug is because of this dependency, or there is an another way to fixed expect of upgrade react-router's version.

And part of package.json for a demo:

{
  "dependencies": {
    "react": "^16.8.6",
    "react-admin": "^2.8.5",
    "react-dom": "^16.8.6",
    "react-router": "^5.0.0",
    "react-scripts": "2.1.8"
  },
}

@fzan
Copy link
Contributor

fzan commented Apr 19, 2019

+1 for warnings in console

@blamze
Copy link

blamze commented Apr 19, 2019

I confirm that I get same warrning too, even though I'm using newest react-admin and react-router in my project

"react-router": "5.0.0",
"react-admin": "2.8.5",

And these errors only occured when I've added react-admin

Still hoping for a fix, because it's annoyng to ignore those warrning

@fzaninotto
Copy link
Member

fzaninotto commented Apr 19, 2019

I've been trying to reproduce the warnings within the examples, with no success. Even using tag 2.8.5, reinstalling all packages and rebuilding everything, I can't reproduce the warnings.

But I do reproduce them by simply creating a new react application depending on react-admin 2.8.5... I'm really scratching my head over this one. I have an idea for a fix, but since I can't test it, I can't move forward.

P.S.: I understand that you're annoyed by these warnings, but you should understand that they don't come from react-admin. It's ReactTraining/history who added them in a minor release. Feel free to voice your opinion regarding console errors in minor versions in their repository.

@fvieira
Copy link

fvieira commented Apr 19, 2019

@RandalTeng @blamze Installing react-router on your project isn't going to fix the warnings, since both ra-core and ra-ui-materialui still use version 4.2.2 as a dependency.

What did fix the warnings was instaling react-router and react-router-dom at version 4.3.0, and then going to node_modules and copying the packages to the node_modules inside ra-core and ra-ui-materialui.

Of course this isn't a proper fix, but it does seem to confirm my thesis...

@djhi
Copy link
Collaborator

djhi commented Apr 19, 2019

If using yarn, you may try the resolutions. Can't remember the equivalent in npm though

@fzaninotto
Copy link
Member

Resolutions don't work on our monorepo (using yarn 1.15.2, which is the latest version available). But I've managed to reproduce the problem by editing the yarn.lock manually (!) and forcing resolution of history to 4.9.0 (which is what yarn does on new projects but, for some reasons, refuses to do on our monorepo). I've therefore been able to test my fix, which I'll open a PR for.

@RandalTeng
Copy link

Resolutions don't work on our monorepo (using yarn 1.15.2, which is the latest version available). But I've managed to reproduce the problem by editing the yarn.lock manually (!) and forcing resolution of history to 4.9.0 (which is what yarn does on new projects but, for some reasons, refuses to do on our monorepo). I've therefore been able to test my fix, which I'll open a PR for.

It's always cool. Thank you very much. And this issue should to be closed?

@handreistoicescu
Copy link
Author

Sorry to ask, but I'd need to clear this up: is this fixed now? I mean, are the errors in the console gone?

@djhi
Copy link
Collaborator

djhi commented Apr 19, 2019

We just merged the PR. This will be available in the next release

@handreistoicescu
Copy link
Author

Perfect. Thank you for your work on this!

ghodsizadeh pushed a commit to ghodsizadeh/react-admin that referenced this issue May 21, 2019
@honey-saini
Copy link

i solved the problem just by installing react router and react router dom of version 4.3.0

@jonorril
Copy link

jonorril commented Aug 4, 2020

This seems to be caused by the react-router-dom dependency of ra-core which is on version 4.2.2 and has been fixed since version 4.3.0-rc.1.

This is the commit that fixed it:
ReactTraining/react-router@a3e6fac#diff-03323cab9211ecbb380f296cabff2285

this fixed it for me

sven-walsted pushed a commit to sven-walsted/USWDS-React that referenced this issue Feb 13, 2021
The require in <Main/> wasn't importing the correct components. There
was a warning caused by ReactRouter, that was fixed by relaxing the
version.

marmelab/react-admin#3138
sven-walsted pushed a commit to sven-walsted/USWDS-React that referenced this issue Feb 13, 2021
The require in <Main/> wasn't importing the correct components. There
was a warning caused by ReactRouter, that was fixed by relaxing the
version.

marmelab/react-admin#3138
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants