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

moment is not a function? #5444

Closed
mathritter opened this issue Apr 14, 2020 · 3 comments
Closed

moment is not a function? #5444

mathritter opened this issue Apr 14, 2020 · 3 comments

Comments

@mathritter
Copy link

Can't even execute the example shown in https://momentjs.com/docs/#/use-it/typescript/
Any help or advice? Seems like a bug
image

error:

moment is not a function. (In 'moment()', 'moment' is an instance of Object)

  • components\Calendar.tsx:25:20 in prepareMomentJS
  • components\Calendar.tsx:21:4 in componentDidMount
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:17028:11 in commitLifeCycles
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:20001:23 in commitLayoutEffects
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:306:6 in invokeGuardedCallbackImpl
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:530:2 in invokeGuardedCallback
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:19766:6 in commitRootImpl
  • [native code]:null in commitRootImpl
  • node_modules\scheduler\cjs\scheduler.development.js:642:6 in unstable_runWithPriority
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:19588:6 in commitRoot
  • [native code]:null in commitRoot
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18708:6 in runRootCallback
  • [native code]:null in runRootCallback
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5641:13 in runWithPriority$argument_1
  • node_modules\scheduler\cjs\scheduler.development.js:642:6 in unstable_runWithPriority
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5637:18 in flushSyncCallbackQueueImpl
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18794:29 in batchedUpdates$1
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2708:6 in batchedUpdates
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2793:13 in _receiveRootNodeIDEvent
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:432:6 in __callFunction
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17 in __guard$argument_0
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:383:10 in __guard
@Alanscut
Copy link
Contributor

@mathritter Please see stackoverflow here for the complete solution.
https://stackoverflow.com/questions/56503281/typescript-import-as-moment-from-moment-vs-import-moment-from-moment

@marwahaha
Copy link
Member

I'll take a PR at https://github.com/moment/momentjs.com/

@marwahaha
Copy link
Member

The docs are updated.
Please re-open if you still have concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants