简体   繁体   English

react-dates 库对大多数组件的渲染问题

[英]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所有其他组件,如DayPickerRangeControllerPresetDateRangePicker给我这个错误

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 .我需要使用DayPickerRangeControllerPresetDateRangePicker 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM