wakwak wakwak - 1 year ago 56
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();