I follow the tutorial from http://intljusticemission.github.io/react-big-calendar/examples/index.html
so I write a sample, but when I run ,
it shows the message below :
Uncaught TypeError: moment is not a function
at DateLocalizer.format (moment.js:22)
at _format (localizer.js:21)
at DateLocalizer.format (localizer.js:47)
at DateLocalizer.format (moment.js:22)
at _format (localizer.js:21)
at DateLocalizer.format (localizer.js:47)
at Object.format (localizer.js:84)
at viewLabel (viewLabel.js:35)
at Calendar.render (Calendar.js:172)
at ReactCompositeComponent.js:796
can anyone tell my what's going on? thx
my snippet code
BigCalendar.setLocalizer(
BigCalendar.momentLocalizer(moment)
);
const MyCalendar = props => (
<div>
<BigCalendar
events={events}
startAccessor='startDate'
endAccessor='endDate'
/>
</div>
);
you need to import moment or otherwise make it available
I already import node_module/lib/localizers/moment
if I add 'culture' props the message become " m.locale is not a function "
You have to install moment, e.g. npm install --save moment, and then import it like this:
import moment from 'moment'.
In typescript
import moment from 'moment'
TS1192: Module '"/node_modules/moment/moment"' has no default export.
Most helpful comment
You have to install moment, e.g.
npm install --save moment, and then import it like this:import moment from 'moment'.