React-datepicker: DatePicker doesn't work with React 16.4

Created on 27 Jun 2018  路  7Comments  路  Source: Hacker0x01/react-datepicker

Expected behavior

I already used Datepicker in a lot of different app and got no problems

Actual behavior

Now with React 16.4, when I try to render a normal DatePicker, app's crash.

render(){
<DatePicker selected={moment()} onChange={this.onChange} />
}

I got this error

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object

I tried with version 1.4.1 (who was working in a older app) and with 1.5.0 and no one is working.

wontfix

Most helpful comment

doesn't work for me as well.. a problem with react-popper

All 7 comments

doesn't work for me as well.. a problem with react-popper

This type of message usually indicates that you've imported the library improperly and ended up with something like { default: DatePicker } rather than just DatePicker. Maybe your tooling or build changed at the same time you upgraded React?

Yes i was thinking it was bad imported/builded but I tried to remove all my node_modules and to re-install them with yarn and npm but got the same issue.

But yes I expect an error with the import/build I don't know how I can check this...

More than half a year old. Anybody fix this problem? I have the same one. Yes, I am doing import Datepicker.

Just an update for anybody who stumbles upon this problem. I noticed the error was with popper and went over to their GitHub, where some people had the exact same issue and suggested making sure your react and react-dom are the same version. I tried that and had no luck. Then I stumbled upon another solution for a completely unrelated project but same error, where people suggested deleting your node_modules directory and starting over. It worked.

tl;dr: if you're getting this problem, it's probably because something is screwed up in your node_modules, which is causing a dependency of react-datepicker to fail. Delete the folder and install everything fresh.

ran into the same problem, I was updating datepicker from a legacy version of 1.2.7 to 2.7.0

after deleting the datepicker folder under node_modules and running npm install again, it fixed the issue

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dhruvparmar372 picture dhruvparmar372  路  3Comments

evolve2k picture evolve2k  路  3Comments

lclemence picture lclemence  路  3Comments

jcabrerazuniga picture jcabrerazuniga  路  3Comments

ericreis picture ericreis  路  3Comments