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

When moving to <Link>, LOCATION_CHANGE is called twice. #509

Open
joyfuI opened this issue May 12, 2021 · 4 comments
Open

When moving to <Link>, LOCATION_CHANGE is called twice. #509

joyfuI opened this issue May 12, 2021 · 4 comments

Comments

@joyfuI
Copy link

joyfuI commented May 12, 2021

I am migrating a project that used react-router-redux to connected-react-router.

Looking through the console logs, I noticed that LOCATION_CHANGE was being called twice every time a page was navigated.

Here is the reproduction code.
https://codesandbox.io/s/connected-react-router-0tbdu

Is this the correct behavior?

@Akiyamka
Copy link

I see the same behavior (twice LOCATION_CHANGE) even when dispatch the push action.
Relative issue: #318

@joyfuI
Copy link
Author

joyfuI commented Jun 6, 2021

I found the cause. StrictMode is the cause.

After further searching, I found the following article:
https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects

It's probably caused by two renderings in development mode with StrictMode.

@cll123456
Copy link

@joyfuI you are right, thanks your useful advice

@pr1ntr
Copy link

pr1ntr commented Nov 18, 2021

So should we just not use this library in conjunction with Strict Mode? Surely Strict Mode has a lot of benefits. What exactly is the issue with history as per #318?

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

4 participants