Here is why view doesn't get updated when you change your route. And it is also described in react-redux
troubleshooting section.
If your views depend on global state or React “context”, you might
find that views decorated with connect() will fail to update.
This is because connect() implements shouldComponentUpdate by default,
assuming that your component will produce the same results given the
same props and state. This is a similar concept to React’s
PureRenderMixin.
So the problem is within your ConnectedSwitch
which will work if you change it to:
const ConnectedSwitch = connect(
state => ({
location: state.location
}),
null,
null,
{ pure: false }
)(Switch);
or
const ConnectedSwitch = withRouter(
connect(state => ({
location: state.location
}))(Switch)
);
It seems to me that state.location
even though is coming from redux is being mutated not updated. That's why shouldComponentUpdate
implemented by connect
returns false.
Unfortunately, I don't get:
Cannot read property 'email' of undefined
so I don't know how to help you with that.