score:2

Accepted answer

you are probably facing the problem react router have with update blocking. this happens because redux avoids re-renders and call mapstatetoprops, instead.

to prevent this behavior your can pass the option pure: false in react-redux connect function.

example:

connect(mapstatetoprops, null, null, { pure: false })(component);

you can head to react redux api documentation to see more details on this option.

score:0

as an alternate you can use withrouter

import { withrouter } from 'react-router-dom';
.
.
export default withrouter(connect(mapstatetoprops)(approutes));

references-

  1. https://github.com/reacttraining/react-router/issues/4671
  2. https://reacttraining.com/react-router/web/api/withrouter

Related Query

More Query from same tag