反应:未捕获的TypeError:无法读取未定义的属性“年”

时间:2020-04-08 20:35:48

标签: javascript arrays reactjs

我正在尝试使用react钩子创建日历,但是出现以下错误

proc = ctx.Process(target=my_func, environment={"MY_NAME": "MY_VALUE"})

这里是引起问题的函数,尤其是这一行Store.js:3661 Uncaught TypeError: Cannot read property 'year' of undefined at Function.diff (Store.js:3661) at Function.interval (Store.js:3674) at Store.js:88850 at Array.map (<anonymous>) at renderCalendarDays (Store.js:88849) at EventCalendar (Store.js:88867) at renderWithHooks (Store.js:47072) at mountIndeterminateComponent (Store.js:49487) at beginWork$1 (Store.js:50836) at HTMLUnknownEl ;

const isToday = Calendar.interval(day, today) === 1

不幸的是,我正在努力解决问题,有人可以帮助我吗?

这里的代码有什么问题?

1 个答案:

答案 0 :(得分:0)

据我了解,您为Object状态的默认值分配了today。让我们考虑一下您的对象是带有某些伪数据的{day:1, month:2, year:3}。现在,如果要访问该对象的任何属性,则需要调用例如:today.day而不只是today