You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello 馃憢, I observed a strange behavior after upgrading react-router-dom from v5.1.2 to v5.2.0. It looks like history.push or history.replace (taken from useHistory) doesn't trigger anymore a re-render when a search param has changed.
Here, calling history.push changes the URL but doesn't re-render the counter... It's a bit annoying as this minor version has introduced a breaking change in our application.
Is it normal? 馃檪
The text was updated successfully, but these errors were encountered:
mattp94
changed the title
[Bug]: history.push no longer triggers a render when a search param has changed
[Bug]: history.push no longer triggers a re-render when a search param has changed
Jul 23, 2021
It might be related to #7103 or #7288, but much probably was the update of mini-create-react-context because the changes over useLocation were minimal and basically entire related to just create a context from mini-create-react-context as long as the problems seem to be on the context re-render updating once the history.push is correctly working.
What do you guys think @timdorr and @mjackson? There's anything wrong with the code in those codesandbox links?
You're not subscribing to any location change. You're relying on an old performance-related bug that we fixed in 5.2. Use the useLocation hook instead and it works just fine:
What version of React Router are you using?
5.2.0
Steps to Reproduce
Hello 馃憢, I observed a strange behavior after upgrading
react-router-dom
from v5.1.2 to v5.2.0. It looks likehistory.push
orhistory.replace
(taken fromuseHistory
) doesn't trigger anymore a re-render when a search param has changed.Expected Behavior
Here is a simple example with v5.1.2:
https://codesandbox.io/s/with-react-router-dom-512-before-zljp8
As you can see, calling
history.push
changes the URL as well as the counter value. So everything works well!Actual Behavior
Now, when I test with v5.2.0, it no longer works:
https://codesandbox.io/s/with-react-router-dom-520-after-z796t
Here, calling
history.push
changes the URL but doesn't re-render the counter... It's a bit annoying as this minor version has introduced a breaking change in our application.Is it normal? 馃檪
The text was updated successfully, but these errors were encountered: