Closed VanessaChu closed 6 years ago
If moment.duration.fn.format
is not a function, it means that when the moment-duration-format
plugin was imported, it couldn't figure out what moment instance to use. The plugin module exports its setup function, so you'll need to do something like this (I'm not totally sure how it should look with the import
style of including a module):
var newMomentInstance = import moment from 'moment/min/moment-with-locales';
var momentDurationFormatSetup = import 'moment-duration-format';
momentDurationFormatSetup(newMomentInstance);
@VanessaChu let me know if you haven't resolved your issue. Closing this for now.
I'm using React Native and I'm trying to change the language of my moment.js by changing import moment from 'moment' to import moment from 'moment/min/moment-with-locales'.
import moment from 'moment/min/moment-with-locales' import 'moment-duration-format' // used by moment
However, I get an error "momentWithLocales2.default.duration(...).format is not a function" at this line:
const total = moment.duration(this.props.stoveUsage.total, 'seconds').format('H:mm', { trim: false })
before there was no error with just import moment from 'moment'