push()即使我推送相同的url也会调度LOCATION_CHANGE操作

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

本文关键字:url 调度 LOCATION 操作 CHANGE push      更新时间:2023-09-26

我使用内置的react-router-redux push() action-creator在我的应用程序中导航路由。即使我推送与前一个相同的URL,它也会调度LOCATION_CHANGE动作。

是默认行为吗?如果是,我是否可以在不编写额外中间件的情况下对其进行更改?

当你从动作创造者dispatch一个动作时,你通常期望一个动作被分派。是的,这是一个默认行为。

你可以在这里看看动作的实现

您可以在调度操作之前检查您的位置,如下所示:

import { history } from './app.js'; // file where you export history instance
const location = history.getCurrentLocation();