-
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/replaceState, use push/replace instead #162
Comments
👍 |
I'm 👎 on this. The intention of #141 is to move the API forward by making Going back to a privileged multi-arg form and not offering a full replacement is more complicated for users and doesn't give us as good an API. |
To be clear, I'm just for the deprecation of the |
Yup - understood, and in a vacuum I'd consider However, both APIs are worse than
Thus IMO we shouldn't set up the |
I'd vote: // the majority case
push('/some/where')
// the rest
push({ path: '/some/where', query: {}, state: {} }) |
I'm also for interchangeable string and objects. The object form is basically Javascript's version of keyword args from Ruby or Python (when you destructure the object arg). And kwargs are the bomb dot com, so I'm always up for that. Another big advantage is the args are no longer ordered, so if we add more, there is less breakage during upgrades. Makes API changes less hairy and keeps work in related projects (router, etc.) to a minimum. I'm with @taion and @ryanflorence on this one. |
Great, if you like that API, it's coded up on #141. |
And I'd really appreciate feedback on implementation, specifically regarding the workaround in |
Given the above, are we okay with deferring this until after we merge #141, and then transitioning directly to the object-based If so, we might want to edit the OP to note the object-based API, rather than optional args. |
It's not important to me that The important part of this issue is that the whole idea of state should be optional without the user having to explicitly pass |
That makes sense. I'm actually coming at this from a different angle - I care a lot about the API to history.push({path, query}) Something like a history.push({name, params, query}) The flexibility has the potential to be invaluable in building out RN support, because it gives us a lot of power in iterating on the specific API for update specs, without needing to change any API contracts between the router and history. I agree that it's an API detail, but to me it's a very important one - by asserting that the argument is a flexible object, and not making any assumptions on the rest of the signature, we end up ripping out all the assumptions about how locations are constructed, which is a lot of flexibility at relatively low cost. |
What sort of timing are we thinking here w/r/t release schedule? Do we want to fully drop |
One more thought - if we drop the browser-compatible APIs, I think we end up breaking people like @natew who per #121 (comment) appears to just be using |
If you're setting up a window.history.pushState = function(state, title, url) {
hashHistory.push({ path: url, state: state})
} I've always felt a little funky about co-opting a public API, but not explicitly being a polyfill library. |
Sure - we can also do e.g. |
Yes. I don't want to ship 2.x with two different APIs for push/replace.
Agreed. Using the names |
We're not a polyfill. If someone wants to make a polyfill using history, they should be able to do it easily. But I don't think we should be concerned with it. |
Yeah, easy enough to add an enhancer. The #141 already made e.g. |
Yes, let's deprecate them in the next minor release.
|
I'll add the deprecations to #168, since they're touching on the same docs there anyway. Let's also figure out how to cut RR 1.1.0, then, since I don't want to show deprecation warnings to all of our users who are using |
Let's follow up in #168. |
Hi @mjackson, I wonder what was the reason you've decided to deprecate these functions out of the sudden. |
We should deprecate the
pushState
/replaceState
APIs and just usepush
/replace
instead with an optional 2ndstate
argument. This is the API that @th0r originally suggested in #118, but I didn't get it at that time (not sure why).This will save everyone passing
null
as the state argument topushState
andreplaceState
all the time when they're not usinglocation.state
.The text was updated successfully, but these errors were encountered: