Uncaught TypeError: momentFn is not a function
I've already got installed moment, react but getting this error on rendering Using latest version of react-datetime
Uncaught TypeError: momentFn is not a function
at Object.localMoment (DateTime.js:372)
at Object.getFormats (DateTime.js:122)
at Object.getStateFromProps (DateTime.js:66)
at Object.getInitialState (DateTime.js:55)
at new eval (factory.js:789)
at eval (ReactCompositeComponent.js:295)
at measureLifeCyclePerf (ReactCompositeComponent.js:75)
at ReactCompositeComponentWrapper._constructComponentWithoutOwner (ReactCompositeComponent.js:294)
at ReactCompositeComponentWrapper._constructComponent (ReactCompositeComponent.js:280)
at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:188)
I'm Submitting a ...
[x] Bug report
[ ] Feature request
[ ] Support request
According to this article https://stackoverflow.com/questions/33704714/cant-require-default-export-value-in-babel-6-x the problem is in the wrong way of moment module requiring in file DateTime.js on line 6 .
It should look like moment = require('moment').default, to work with Babel 6.
@djakuzey answer is correct, it solved the problem for me.. Just wondering when will it be included on next release?
Apparently the changes also needs to be made on DaysView.js..
I'm using a fork to solve this issue as well for now. Side note, even though Babel 6 is being used, the tests fail when require('moment').default
I also have this error. Since it has fix solution, when it could be fixed in release ?
Hey people, sorry for the delay. It looks like this is still a problem.
I'm glad you found the problem and a solution. Does anyone know if this would break usage with Babel version <6?
Although require('moment').default fixed module resolution in transpiled browser code, it would break usage in node.js. May be something like if (moment.default) { moment = moment.default; }?
@simeg Maybe this could help: https://www.npmjs.com/package/babel-plugin-add-module-exports
Why is this not yet fixed?
I'd be happy to submit a PR for this if that would help. Basically would follow the suggestion posted by @kaid
Thoughts?
I've just hit the problem and am wondering why this is still open. Apparently, not everybody is affected by this issue, otherwise I'd assume that it'd be fixed already.
still cant get this to work on latest version with babel7 and webpack 4, is this library abandoned?
@YouCanBookMe - Just curious if you are looking for maintainers. I can create a PR for this, but I don't want to do the work unless there is a good chance of it getting merged in.