history.listen() v4 -> v5 compatibility

Created on 4 Jan 2020  ·  5Comments  ·  Source: ReactTraining/history

Hi, I noticed a change in the history.listen method.

The change is on this line: https://github.com/ReactTraining/history/pull/751/files#diff-c427a522f4ea08a4c045a518ac721ce9R34

history.listen((location, action) => {})
is now
history.listen(({ location, action }) => {})

If there is no reason to this change except syntax sugar then I would like to suggest to revert this.

Reason: If you have an application where the history instances are swappable then it would be great to allow v4 and v5 instances to be interchangeable. That way a developer can elect to use an older version of the package to gain back some removed features (like basename support).

With this change anyone that wants to do that now has to change their code to be compatible.

Most helpful comment

I'm ok with breaking changes, what is frustrating is that this _very_ breaking change is not mentioning in the v5.0.0 release notes under “Breaking Changes”:

https://github.com/ReactTraining/history/releases/tag/v5.0.0

All 5 comments

With this change anyone that wants to do that now has to change their code to be compatible.

That's why SemVer exists. Updating from v4 to v5 is a breaking change by default.
https://semver.org/#spec-item-8

I'm ok with breaking changes, what is frustrating is that this _very_ breaking change is not mentioning in the v5.0.0 release notes under “Breaking Changes”:

https://github.com/ReactTraining/history/releases/tag/v5.0.0

yea it's a fucking headache to deal with

this history v5 and react router v6 is just a clusterfuck of migration to deal with

I also don't see the huge advantage of this change... However, changing it back would be another BC break, causing more headaches for people who have already changed it :see_no_evil: But it should definitely be mentioned in the release, I was reading the breaking changes and assumed that I won't need any migration, because the changes mentioned there didn't affect my application.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sidoruk-sv picture sidoruk-sv  ·  3Comments

johnjesse picture johnjesse  ·  6Comments

govizlora picture govizlora  ·  5Comments

andi5 picture andi5  ·  6Comments

clayrisser picture clayrisser  ·  4Comments