Search code examples
javascriptreactjsreact-dates

react-dates library's render issue for most of the components


I am trying to use airbnb's react-dates on my project. You can get the project here

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. I was only able to render when I used DateRangePicker. All other components like DayPickerRangeController and PresetDateRangePicker giving me this error

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.

I need to use DayPickerRangeController and PresetDateRangePicker. Can anyone tell me what I am doing wrong here?


Solution

  • 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.

    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