-
Notifications
You must be signed in to change notification settings - Fork 961
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
Deprecate pushState and replaceState for new push and replace #168
Conversation
ae4903d
to
9ac2626
Compare
@@ -115,6 +115,23 @@ A *location key* is a string that is unique to a particular [`location`](#locati | |||
|
|||
type LocationListener = (location: Location) => void; | |||
|
|||
### LocationSpec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm like ~65% on this.
We lose a bit of conciseness by introducing this concept of a "location spec" object, but I think it's worthwhile to not entirely merge this concept into that of a "location", because of the omission of the action
and key
fields.
I'd be totally fine with merging this into the concept of a location
if people feel that would make more sense, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I think this is the way to go.
This builds on top of the updated CHANGES format per #167, because I wanted to call out new features separately from bug fixes. |
Added a WIP with the deprecations. Still need to change the tests - thinking of putting together a codemod for that. |
@@ -1,5 +1,11 @@ | |||
## [HEAD] | |||
|
|||
#### New features |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to further sub-divide this doc? I was hoping to keep each release small enough that we wouldn't have to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about labelling it as something like:
- Feature: Accept objects in
history.push
andhistory.replace
([Accept objects in push and replace #141]) - Deprecation: Deprecate
history.pushState
andhistory.replaceState
in favor of passing objects tohistory.push
andhistory.replace
([Deprecate pushState and replaceState for new push and replace #168]) - Bugfix: Disable browser history on Chrome iOS ([Disable browser history on Chrome iOS #146])
- Bugfix: Do not convert same-path
PUSH
toREPLACE
if the hash has changed ([Consider the full path in changing PUSH to REPLACE #167])
I just want an easy way for people looking at this to tell at a glance what has changed in which way - especially new features and deprecations, which might require some action on their part.
Looking good, @taion 👍 Just let me know when you're ready to merge. |
Probably not today unless it's later : I was hoping to use JSCodeShift to update the tests, but I have to learn how to use JSCodeShift first. |
I mean, not because there are so many tests that I can't update them by hand, more that I think JSCodeShift is super cool, and that it'd be nice to offer a codemod to our users. |
Continuing from remix-run/react-router#2646 (comment), the "location descriptor" or "location spec" or whatever is slightly different enough that we'd avoid some confusion by calling it something else. There's no One example of the difference is that when using queries, your "location descriptor" might look like: {
pathname: '/foo',
query: { the: 'query' },
} But the corresponding "location" is more like: {
pathname: '/foo',
query: { the: 'query' },
search: '?the=query',
action: 'POP',
key: 'asdf12',
} It's really a shorthand object that is enough to describe or specify a location, but is not a location itself. |
Got the codemod running: https://gist.github.com/taion/0b752445e86304f5f5c2 Doing final cleanups now, will update PR shortly. What do we want to do with the transform? Ideally we'd ship it to users somehow. |
PR updated. This is ready to go from my end, assuming we don't want to ship the transform with this package. I'm really impressed with JSCodeShift. All the test updates on the 2nd commit were with JSCodeShift, except:
|
Thanks @taion. I'll take a look.
|
You could drop it in the |
Sorry, had to manually update a few more tests. There were a few meant to intentionally cover |
@timdorr It's not a script per se, though - you can only run it through |
Yeah, but you would run it once for automating the upgrade to this API version. That sounds script-y to me 😄 |
Oh, I missed the "single quote" recast option. Well, ESLint fixed it for me anyway. @timdorr I was thinking of using |
Assuming we go forward with this PR as-is or in slightly modified form, I'm going to set up a rackt-codemod repo under this org, and distribute the codemod there. |
I was just going to suggest this. If you don't mind, could you create separate folders for each repo that has codemods (just history for now)? |
👍 Will do. |
@taion Looks like you're ready to merge here? |
@@ -105,6 +104,23 @@ A *location* answers two important (philosophical) questions: | |||
|
|||
New locations are typically created each time the URL changes. You can read more about locations in [the `history` docs](https://github.com/rackt/history/blob/master/docs/Location.md). | |||
|
|||
### LocationDescriptor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for this name. I was actually thinking about using this name too :)
Yes, this is good to go from my end. Anything else I need to fix before we merge? |
@taion Needs a rebase on master now. |
Yup, done! Thanks. |
Thanks, @taion. This turned out to be quite a bit of work! |
Deprecate pushState and replaceState for new push and replace
It was fun, though, and the long-term API cleanup is going to be really sweet. Just need to fix |
Oh crud, the warnings for |
No description provided.