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

Make hash history "same path" warning use console.warn #488

Open
mgustin12 opened this issue Jun 8, 2017 · 5 comments
Open

Make hash history "same path" warning use console.warn #488

mgustin12 opened this issue Jun 8, 2017 · 5 comments

Comments

@mgustin12
Copy link

Could the 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack' warning be turned into a console.warn rather than a console.error? When using React Router, this warning will spam the console cause confusion and concern. Changing the warning to a console.warn will better serve it's purpose.

Also, console.warn on it's own does not support all browsers, so a different method might be required.

Line of interest: https://github.com/ReactTraining/history/blob/master/modules/createHashHistory.js#L217

Current:
hashpoppingslasher

Desired:
hashquietpopper

@mjackson
Copy link
Member

Agree this warning can be annoying. We're currently using the warning library to issue the warning, but it uses console.error under the hood in browsers.

Looking into this a bit further, it looks like they are opposed to using console.warn essentially because console.error provides better stack traces. I encourage you to click through on that one. There are some good links in that thread.

Anyway, we don't really need a stack trace, so I'd be open to switching to a console.warn for just this warning. We will need to do 2 things:

  • make sure the browser supports console.warn and
  • make sure the warning is stripped out of the production build

If we can do both of those I'd say we're good to go.

@mjackson mjackson changed the title Make Hash History warning console error into a console warning Make hash history "same path" warning use console.warn Jul 19, 2017
@ZoeVonFeng
Copy link

Hi, I am having such warning/error spamed everytime I click my link. Should I be concerned?

@462960
Copy link

462960 commented Nov 25, 2017

I do have the same warning, URL shows my path but there is no redirection. Any clue would be appreciated.

@mischah
Copy link

mischah commented Mar 28, 2018

Hej @mjackson,

would you accept a PR for this?

I would also recommend renaming extending that warning to make it clear how it was caused. It took me a while to get that this isn’t something I caused with a wrong setup 😆

Maybe replace:

Hash history cannot PUSH the same path; a new entry will not be added to the history stack

with:

You are already on the desired location. Hash history cannot PUSH the same path; a new entry will not be added to the history stack.

Or even easier to grasp:

You clicked on a linking pointing to your current location. Hash history cannot PUSH the same path; a new entry will not be added to the history stack.

@mjackson
Copy link
Member

Hey everyone, sorry for the delay here.

Yes, I'd be happy to accept a PR here if anyone's up for it. It's not super high priority for me since this warning only appears in development.

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

No branches or pull requests

5 participants