-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[3.0] Remove deprecations. #3340
Conversation
Removing many of the deprecations involves fairly interdependent code, so this will be just one single PR for a bunch (all?) of the deprecations. |
d76c3a3
to
4d43bf4
Compare
warning(false, '`Router` no longer defaults the history prop to hash history. Please use the `hashHistory` singleton instead. http://tiny.cc/router-defaulthistory') | ||
createHistory = createHashHistory | ||
} | ||
history = { ...history, ...transitionManager } |
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.
Don't need the "routing history" any more. This function shouldn't return history
at all.
15016f2
to
ee3d058
Compare
Do you mind if we leave this PR open until we've taken everything out, so that we still have access to the PR comments? BTW, the idea w/ |
Yeah, no rush on this. |
9aedfec
to
0dca89a
Compare
} else { | ||
nextStateWithLocation = { ...nextState, ...location } | ||
getComponent.call(route, nextState, callback) |
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.
Nit: this shouldn't be in an else
. A number of linting rules prohibit "pointless" else clauses per https://github.com/airbnb/javascript/blob/a9db06e1ddbefe3342a61b649c104420d82ba37d/packages/eslint-config-airbnb/rules/best-practices.js#L39. Just put this outside the if
block as in #3348.
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.
Oh, I see what you did – the idea with the !getComponent
check above and the reason I just bail out there is because it's intended as a guard clause. Otherwise we should probably invert the order of the branches.
5e49a1e
to
eab6f08
Compare
Rebased against next, which was updated against master. Anything left? I think this is good to go. |
@@ -226,15 +210,6 @@ export default function createTransitionManager(history, routes) { | |||
if (history.listenBeforeUnload) | |||
unlistenBeforeUnload = history.listenBeforeUnload(beforeUnloadHook) | |||
} | |||
} else { | |||
if (hooks.indexOf(hook) === -1) { |
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.
This is not quite right – RouteHooks[routeID]
should actually no longer be an array at all, and this else
branch should instead just overwrite the value.
So this whole thing should be something like:
const thereWereNoRouteHooks = !hasAnyProperties(RouteHooks)
const routeID = getRouteID(route)
RouteHooks[routeID] = hook
if (thereWereNoRouteHooks) {
// ...
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.
Ah crap, I was racing through this to get back to work. I'll have to look at it tonight.
Fixed up I'll want to merge up |
https://github.com/reactjs/react-router/blob/d3be55cc6b80506456f3d91e53b52046cb480670/modules/createTransitionManager.js#L104-L107 needs to be updated, something like const hooks = routes
.map(route => RouteHooks[getRouteID(route)])
.filter(hook => hook) |
|
||
if (!hooks) { | ||
let thereWereNoRouteHooks = !hasAnyProperties(RouteHooks) | ||
RouteHooks[routeID] = [ hook ] |
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.
No need for the array here at all, unless I'm missing something.
Ah, that's what I was missing! |
d3be55c
to
56b0be0
Compare
return hooks | ||
}, []) | ||
return routes | ||
.map(route => RouteHooks[getRouteID(route)]) |
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.
Oops, this should probably be getRouteID(route, false)
, actually. No reason to create route IDs here. The undefined
will safely avoid colliding with any actual keys under RouteHooks
.
Something that "gets" shouldn't have a side effect by default.
3a30d28
to
1a5666e
Compare
OK, updated |
Sorry if this is unrelated—shouldn’t https://github.com/reactjs/react-router/blob/next/modules/RoutingContext.js also go? |
Good catch! Yeah, I'll drop that one too. |
See #3336.