React-router version : 4..1.1
This is a problem to get an optimized application when only some part of the app depend on the location, as this means the a major part need to be rerendered for nothing. I know it is a well known problem of react context, and therefore not specific to react-router.
There seem to be a solution to such a problem explained on this medium blog post: medium. This solution is given on React's website as a possibility to fix the issue.
Basically, the idea is to have Route, Switch and Redirect components subscribe to an change of location context, and rerender them using setState.
I will try such a solution by wrapping Route and Switch so that the subscribe to location update and see how this behaves in real life application.
Thanks for providing <Switch>
@ReactRouter4Team
It solved a lot of problems for our project.
@timdorr
Thanks for reading me and writing such a long answer, but the link you gave just tells 'pass down the location/match objects as props, it will rerender'. Well, that'show React works.
Having to do such is really disappointing when you are used to react-redux, and used to rerendering only the required components.
Route and Switch are expected, on a developper's point of view, to rerender on location change (if matching), without needing to rerender the parent component. As I explained in the initial issue, on normal apps, it is not expected to rerender the full app on each user action.
Most helpful comment
@timdorr
Thanks for reading me and writing such a long answer, but the link you gave just tells 'pass down the location/match objects as props, it will rerender'. Well, that'show React works.
Having to do such is really disappointing when you are used to react-redux, and used to rerendering only the required components.
Route and Switch are expected, on a developper's point of view, to rerender on location change (if matching), without needing to rerender the parent component. As I explained in the initial issue, on normal apps, it is not expected to rerender the full app on each user action.