English 中文(简体)
在“过滤器.startDate”(reux-toolkit.esm.js )的道路上发现了非空中价值。
原标题:A non-serializable value was detected in the state, in the path: `filters.startDate` (redux-toolkit.esm.js )

I m building a budget App using React 18 and Redux I don t know what is the problem here

import moment from "moment";

const filtersDefaultState = {
  text: "",
  sortBy: "date",
  startDate: moment().startOf("month"),
  endDate: moment().endOf("month"),
};

我在增加时间之后再谈这个问题。

redux-toolkit.esm.js?8bb3:444 A non-serializable value was detected in the state, in the path

“Errorography”/

资料来源:Github:https://github.com/KhaledGharib/visionApp

利用日期

最佳回答

这里的问题是<代码>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;
};
问题回答

您可以通过添加<条码>至ISOString(<>条码>>的功能,或者如果你使用红色高射线(<>条码/代码>至<条码>,简单地设定<条码>>不可扩展的Check。

 const store = configureStore({
    reducer: rootReducer,
    middleware: (getDefaultMiddleware) =>
      getDefaultMiddleware({serializableCheck:false}).concat(yourCustomMiddleWare),
  });




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签