Based on the use of the @observer
decorator, it seems like you are using mobx-react
. What you need to know about observer
is that it implements shouldComponentUpdate
to optimize rendering performance. This sCU
call will look at the current and next details, and if there is no difference, it will not be re-rendered. This is a problem because, by default, the React Router uses context to transfer data and uses re-rendering of elements to get updated values, but observer
sCU
not able to detect context changes.
The way you can get around this is to pass the location
object as a support for the component wrapped by the observer
. Then, when the location changes, observer
shouldComponentUpdate
detect the difference and re-render.
You can see the blocked upgrade guide for more information.
source share