[英]react-dates library's render issue for most of the components
I am trying to use airbnb's react-dates on my project.我正在尝试在我的项目中使用 airbnb 的react-dates 。 You can get the project here
你可以在这里得到项目
https://codesandbox.io/s/react-date-nufy9?file=/src/App.js https://codesandbox.io/s/react-date-nufy9?file=/src/App.js
I am following the documentation of react-dates, but somehow my app fails when I use react-dates's component.我正在关注 react-dates 的文档,但是当我使用 react-dates 的组件时,我的应用程序以某种方式失败了。 I was only able to render when I used
DateRangePicker
.我只能在使用
DateRangePicker
时进行渲染。 All other components like DayPickerRangeController
and PresetDateRangePicker
giving me this error所有其他组件,如
DayPickerRangeController
和PresetDateRangePicker
给我这个错误
Element 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 the render method of
App
.检查
App
的渲染方法。
I need to use DayPickerRangeController
and PresetDateRangePicker
.我需要使用
DayPickerRangeController
和PresetDateRangePicker
。 Can anyone tell me what I am doing wrong here?谁能告诉我我在这里做错了什么?
In the sandbox you provided - you are getting this error because you are trying to import DayPickerRangeControllerWrapper
which is not something that is exported from react-dates
.在您提供的沙箱中 - 您收到此错误是因为您尝试导入
DayPickerRangeControllerWrapper
这不是从react-dates
导出的内容。
Your sandbox seems to work fine if you import DayPickerRangeController
instead of DayPickerRangeControllerWrapper
: https://codesandbox.io/s/react-date-forked-cms7c?file=/src/App.js如果您导入
DayPickerRangeController
而不是DayPickerRangeControllerWrapper
您的沙箱似乎工作正常: https : DayPickerRangeControllerWrapper
? DayPickerRangeControllerWrapper
=/ DayPickerRangeController
/ DayPickerRangeControllerWrapper
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.