1

我只是按照步骤将 react-dates 安装到我的项目中。我将他们的包装器用作“hello world”示例,但无法运行。

https://github.com/airbnb/react-dates/blob/master/examples/DateRangePickerWrapper.jsx

但在第 141 行我收到运行时错误:

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. 
Check your code at DateRangePickerWrapper.jsx:141.
    in DateRangePickerWrapper (at GroupForm.js:253)
    in div (at GroupForm.js:204)
    in div (at GroupForm.js:201)
    in div (at FuseScrollbars.js:155)
    in FuseScrollbars (created by Connect(FuseScrollbars))
    in Connect(FuseScrollbars) (created by Route)
    in Route (created by withRouter(Connect(FuseScrollbars)))
    in withRouter(Connect(FuseScrollbars)) (created by 

我试过不使用包装器,而是直接导入和使用 DateRangePicker,将日期的参数从字符串设置为 moment() 到 PropTypes null。

在我的 index.js 中,我有 import 'react-dates/initialize'; 导入'react-dates/lib/css/_datepicker.css';

但我觉得我没有正确初始化它。也许我的初始化导入没有运行,因此它找不到组件名称?

这是一个使用“create-react-app”创建的项目

4

0 回答 0