Search code examples
javascriptreactjsreduxreact-router-redux

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


I'm using built-in react-router-redux push() action-creator to navigate routes in my application. It dispatches LOCATION_CHANGE 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?


Solution

  • 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();