这里的问题是<代码>moment.js 日标不是JSON序列izable。
您可以“航空”,例如,数据说明:
import moment from "moment";
const filtersDefaultState = {
text: "",
sortBy: "date",
startDate: moment().startOf("month").toISOString(true), // "2023-03-01T00:00:00.000Z"
endDate: moment().endOf("month").toISOString(true), // "2023-03-31T23:59:59.999Z"
};
如果你really希望通过serializabilityMiddleware/a>,你可以选择将这一部分国家排除在外:
import { configureStore, createSlice } from "@reduxjs/toolkit";
import expensesReducer from "../reducers/expenses";
import filtersReducer from "../reducers/filters";
const defaultMiddlewareConfig = {
serializableCheck: {
ignoredPaths: ["filters.startDate", "filters.endDate"],
}
};
export default () => {
const store = configureStore({
reducer: {
expenses: expensesReducer,
filters: filtersReducer,
},
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware(defaultMiddlewareConfig),
});
return store;
};