Reactjs 为什么我会出现Redux突变错误?我如何避免它?

Reactjs 为什么我会出现Redux突变错误?我如何避免它?,reactjs,redux,react-redux,Reactjs,Redux,React Redux,我正在使用moment进行一些日期实用程序,并将数据存储在redux中。填写表单后,在后端搜索数据时,我收到此错误,但我仅在第一次搜索时收到此错误: Error: Invariant failed: A state mutation was detected between dispatches, in the path 'app.departureDate._locale._longDateFormat.ll'. This may cause incorrect behavior. 这是减

我正在使用moment进行一些日期实用程序,并将数据存储在redux中。填写表单后,在后端搜索数据时,我收到此错误,但我仅在第一次搜索时收到此错误:

Error: Invariant failed: A state mutation was detected between dispatches, in the path 'app.departureDate._locale._longDateFormat.ll'.  This may cause incorrect behavior.
这是减速器:

addDepartureDate(state, action) {
   return { ...state, departureDate: action.payload };
}
在这里,我使用数据:

const {
    flightType, 
    localeConfig,
    departure,
    arrival,
    departureDate,
    arrivalDate,
    currency
} = useSelector(state => state.app);
const startDate = departureDate;

仅当从react dates中选择新日期时,该值才会更改,但不会引发错误。然后,我在尝试从后端获取数据后得到错误。

一个
时刻
实例是可变且不可序列化的,因此不应保存在Redux存储中:


喜欢将日期值作为数字时间戳或字符串保存在存储中(即,
date.toISOString()
等)

该状态路径中存储的实际数据类型是什么?它是一个
时刻
实例吗?是的,是一个时刻对象,但被初始化为一个空字符串谢谢,伙计。。。!我真的很感激!!!