wakwak wakwak - 4 years ago 167
React JSX Question

push() dispatches LOCATION_CHANGE action even if I push the same url

I'm using built-in react-router-redux

action-creator to navigate routes in my application. It dispatches
action even when I push the same URL as the previous.

Is it default behavior? And if it is, can I change it somehow without writing additional middleware?

Answer Source

When you dispatch an action from action-creater you usually expect an action being dispatched. So yes it is a default behaviour.

You can take a look at actions implementation here

You can check your location before dispatching action like this:

import { history } from './app.js'; // file where you export history instance

const location = history.getCurrentLocation();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download