Skip to content
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

1.1 context.router #2647

Merged
merged 5 commits into from
Dec 6, 2015
Merged

1.1 context.router #2647

merged 5 commits into from
Dec 6, 2015

Conversation

ryanflorence
Copy link
Member

Peep the commit message.

  • I could use some help updating all the stuff in /docs. Don't worry about CHANGES.md. The changes coming down the pipe after this will require a more cohesive explanation of how to update your code than we can do with each individual commit that changes API.
  • could use help updating all of OUR code to the new API (particularly in Link and in our tests), but that should maybe be a separate pull request just to "prove" that the old API still works (afaict it does, tests pass anyway!).

the upgrading information is jumping ahead a bit,
while I’d love the upgrading information to match
perfectly with then commits, I think the best way
to communicate a clear upgrade path is to do it
cohesively, so I’ll be editing this further when
the other commits land, just dumping it in now so
we don’t forget it!
@ryanflorence
Copy link
Member Author

@timdorr ^ see above if you've got some time to help out

return history.isActive(...args)
}
}
return deprecateObjectProperties({ history, location, router }, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe __DEV__-gate this? Just to strip the warning messages and the extra level of indirection out of production bundles.

EDIT: Should have read the full thing first. Sorry.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe there's a cleaner API for deprecateObjectProperties, it would be nice to get these large strings out of production builds.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For warning and invariant, it's a Babel plugin that strips out the warning messages in production builds.

But I feel like any effort we might want to put into that sort of thing would be better spent on providing codemods for our users to shift to the new API, rather than deprecation ergonomics on our end.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, messages no longer get included in a dev build

class RoutingContext extends Component {

getChildContext() {
const { history, location } = this.props
return { history, location }
const router = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Micro-optimization-ville, population me: it might be good to put this in componentWillReceiveProps after a reference equality check, to avoid re-building the router object unnecessarily.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first tell me how long it takes to do 1 million times in a row.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably 5% to 10% as long as it takes for the GC to clean up all of the replaced router objects :p

But yeah it's probably a pointless micro-optimization.

@mjackson mjackson changed the title 1.1 context.router 1.1 context.router [NOT READY YET] Dec 6, 2015
@mjackson
Copy link
Member

mjackson commented Dec 6, 2015

@ryanflorence Is it your intention to do this in multiple PRs? Or all at once? I changed the title but then realized that maybe you'd like to merge this right now before we merge other stuff yet to come.

@mjackson mjackson changed the title 1.1 context.router [NOT READY YET] 1.1 context.router Dec 6, 2015
@ryanflorence
Copy link
Member Author

We can merge now. I see you're also still on GMT this morning.

@mjackson
Copy link
Member

mjackson commented Dec 6, 2015

Haha, yes. No sleep for me tonight :/

K, I'll go ahead and merge.

mjackson added a commit that referenced this pull request Dec 6, 2015
@mjackson mjackson merged commit 5dd12cd into master Dec 6, 2015
@taion taion deleted the 1.1-context.router branch December 6, 2015 14:02
return deprecateObjectProperties(contextExport, {
history: '`context.history` is deprecated, please use context.router',
location: '`context.location` is deprecated, please use a route component\'s `props.location` instead. If this is a deeply nested component, please refer to the strategies described in https://github.com/rackt/react-router/blob/v1.1.0/CHANGES.md#v110'
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, because of the way this is implemented, you'll run into these deprecation warnings all the time in development. When React goes to check contextTypes, it will run into the getter and fire off the warning. Doesn't matter if you're using the API correctly, it always occurs.

@timdorr timdorr added this to the v1.1 milestone Dec 6, 2015
@timdorr timdorr mentioned this pull request Dec 8, 2015
4 tasks
@lock lock bot locked as resolved and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants