-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Empty routeParams cause #3549
Comments
We could calculate all the route params up front. Alternatively, maybe we should modify how this prop works anyway. It's weird to recalculate it on render for each route. |
I don't think it's safe to use the same empty object – we'd be in a really weird position if someone were to modify that object. In general returning mutable const values from a library is not good practice. I'm thinking we should probably just get rid of It doesn't make a lot of sense to me to make everyone pay the tax per-route of calculating cc @reactjs/routing Thoughts? |
@taion What about changing:
to something like
And maybe the same object needs to be returned for when getParamNames(route.path) is [] |
Hmm, I realized what was your concern. |
I don't think there's much we can do about this in the current API. I would like to look into deprecating Any thoughts? |
Are they able to get around errors like |
It doesn't work for that though – right now Maybe we can fix this in matching, though. |
Eh, I don't really want to fix that. That is a user error/bad practice. I say we drop |
Folded into #3611. |
I have several routes.
They have their shouldComponentUpdate functions called, and the only thing that invalidates them is empty object routeParams (current and previous values are {}).
Am I doing something wrong?
Is there a way not to inject these?
If this is intended, wouldn't it be a good idea to always return the same empty object in getRouteParams.js (maybe overthinking it, if there is another way to solve)
The text was updated successfully, but these errors were encountered: