-
Notifications
You must be signed in to change notification settings - Fork 960
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
[v5] Undocumented breaking changes #811
Comments
|
|
I don't really see that. createLocation was quite the powerful function for calculating route changes. parsePath just splits the string according to spec. But your comment just made me notice that parsePath changed behavior between versions too. |
|
So what, are you guys just gonna leave this issue here, without addressing the fact that you shipped a ton of breaking changes without telling us? At least comment on it and tell us how to fix our projects now. |
I am sure they have seen the thread, but, I agree, an acknowledgement would be nice. However, don't go around demanding stuff. If this upgrade breaks your project report what's breaking, subscribe to this thread for updates, and in the meantime revert to v4. That's how it works. |
@mkarajohn maybe you are right, perhaps I'm being too demanding. But just because maintainers are doing their job voluntarily does not mean they can't be held accountable for ignoring such an important issue for, what, two and a half months now? Especially when it comes to such a fundamental and widely used library as |
@shakhbulatgaz I understand your frustration, v5 is unusable for me too, as it currently stands, however it's not the end of the world. I am just staying on v4 a while longer |
- history not upgraded because of bug in push() which is essential. remix-run/history#811 - eslint not upgraded
While the release is correctly versioned as a new major release, some of the breaking changes are missing from the official changelog.
The following is an incomplete list of breaking changes. Some changes listed in the official changelogs are not mentioned here.
So please consult the official changelogs as well:
Open for list of links
Be aware that some of the changes are also mentioned in the beta changelogs but not repeated in the official 5.0.0 release notes:
Removed APIs
createLocation()
was droppedlocationsAreEqual()
was droppedhistory.length
was dropped #960Renamed attributes and functions
history.goBack()
was renamed tohistory.back()
#829history.goForward()
was renamed tohistory.forward()
Changed APIs
history.listen
The
history.listen()
API changed. The callbacks are now called with an an object of shapeUpdate
instead ofLocation
.This breaks react-router <=5.
Before, the callbacks where called as
callback(location, action)
.Now they are called with invoked like this:
callback({action, location})
.v5 docs
v4 docs
Related issue: #803
TypeScript
The type definitions in history@5 are completely incompatible with the type definitions in
@types/history
. If you depend on the latter, installing history@5 will result in a build failure (see #846, #835).options
The options for
createBrowserHistory
,createHashHistory
andcreateMemoryHistory
all changed shape:baseName
was removed, along with the basename feature itself.forceRefresh
was removed. A replacment mechanism for force refreshes has not been added to 5.0.0keyLength
was removed - key length in location objects is now a fixed length.getUserConfirmation
was removed - entire feature removed (see new blocking system)window
was added.pasePath
parsePath()
changed the handling of falsey values. v4 used to return a default location of{pathname: "/", search: "", hash: ""}
, v5 returns{}
history.location
history.location
is now frozenBlocking
Blocking Transitions
The entire blocking system has been redesigned from scratch and is therefore completely incompatible. Please refer to the v5 documentation for how the new system works:
History v5 Documentation
For comparison, here is the v4 documentation.
Immediately, two changes jump out in particular in terms of API surface. Though the behavior also changed:
history.block()
no longer accepts aprompt
parameter.#830
#921
#933
Miscellanious other changes:
key
attribute on locations was increased from 6 to 8.key
now works with createHashHistory as well.Changes in behavior
encoding / decoding
Pathnames are no longer encoded / decoded the same way.
See #551 and #516 for the background.
Also see #884
history.push exception handling
history.push()
now has a different exception handling for iOS (page reload and loss of state). Basically, the library now forces the location viawindow.location.assign(url);
now, where it did not catch the exception before. Relevant codeThis new handling can also allow for XSS in some cases. See #850
createPath
createPath()
no longer ensures the hash and search portions are properly prefixed before concatination.See issue #813.
This was fixed in pull request 891.
Affected versions are 5.0.0 and 5.1.0. Was fixed in 5.2.0
location.key
The
key
on the default location changed from being not defined to being defined and having the value"default"
.Before:
After:
path resolution
As part of path resolution,
push("#hash")
will no longer clear the search part of the location. This is the default browser behavior, but could still be seen as a breaking change.Path resolution also deviates in other ways from v4 that are not default browser behavior, see issues #808, #814 and #859
Addendum 1: I'm not sure I found all the breaking changes. But appending the changelog by my findings could help people who use history directly to make an upgrade decision and find code they need to change on their end regardless.
Addendum 2: [obsolete]
Addendum 3: Michael commented on the intention behind (some of) the breaking changes and history as a library going forward here: #810 (comment) Quote:
Last Addendum: I have added a couple more breaking changes that issues popped up for since my last update ~1.5 years ago. I also added some references to changes I already documented but that had no prior GH issue.
I suggest to anyone in need of a migration guide should just fork v4 instead or find some other fork / re-implementation.
The text was updated successfully, but these errors were encountered: