Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeError: moment is not a function(…) #1765

Merged
merged 2 commits into from
Oct 31, 2018

Conversation

bladepop
Copy link
Contributor

@bladepop bladepop commented Jun 4, 2018

Hey, I have been using https://github.com/skratchdot/react-bootstrap-daterangepicker which wraps daterangepicker, we've migrated our site to React 16.4 from React 15 and encountered an error with the base library.

"TypeError: moment is not a function"

It appears when inserted into the webpack build, the library tries to use 'moment' however it receives an object instead of moment, the object contains a 'default' property that is the actual moment method.

I've added a check when the package is built via webpack to check if moment is not a function and whether it has a default property, and if so, override moment with moment.default and continue as usual.

This change fixed the error on our project and we're using a forked version for the meantime.

Thanks in advance for this awesome library.

@dangrossman dangrossman merged commit bc645d9 into dangrossman:master Oct 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants