导入ReactDayPicker时获取此未捕获的类型错误

时间:2017-09-07 04:14:39

标签: react-day-picker

我只是在我的文件顶部导入:

import DayPicker from 'react-day-picker'

然后我在我的控制台中收到此错误,似乎无法弄明白。

Weekdays.js?f84d:23 Uncaught TypeError: Super expression must either be null or a function, not undefined
    at _inherits (Weekdays.js?f84d:23)
    at eval (Weekdays.js?f84d:26)
    at eval (Weekdays.js?f84d:77)
    at Object../node_modules/react-day-picker/lib/src/Weekdays.js (person.js:4066)
    at __webpack_require__ (common.js:694)
    at fn (common.js:115)
    at eval (Month.js?f52a:17)
    at Object../node_modules/react-day-picker/lib/src/Month.js (person.js:4014)
    at __webpack_require__ (common.js:694)
    at fn (common.js:115)

2 个答案:

答案 0 :(得分:0)

我在React v0.14.8上,我得到了同样的错误。在react-day-picker的v6.0.0中,一些组件被转换为使用React.PureComponent(在React v15.3.0中引入)。我相信这就是我们收到错误的原因,因为我们的React版本没有React.PureComponent。修复方法是将React升级到v15.3.0 +。

答案 1 :(得分:0)

如果您使用的是react-day-picker v6.0,请尝试升级到v6.2,其中PureComponent已被shouldComponentUpdate替换。这应该与React 0.14 +

保持兼容