Reputation: 1714
So I've read about 15 different posts that have similar issues, but they all seem to be either caused by improperly loading jQuery or improperly loading fullcalendar. However, I know I'm loading both into my component (whether or not I'm doing it properly I'm unsure). I'm using the fullcalendar
npm in my package.json
.
My component:
import React from 'react';
import moment from 'moment';
import fc from 'fullcalendar';
export default class DailyEvents extends React.Component {
constructor(props) {
super(props)
this.state = {
}
}
componentDidMount() {
console.log(fc)
console.log($('#calendar'))
$('#calendar').fullCalendar();
}
render () {
return (
<div id="calendar"></div>
);
}
}
The output I get from console.log(fc)
is:
Object {version: "3.4.0", internalApiVersion: 9, views: Object, intersectRanges: function, applyAll: function…}
AgendaView:function ()
BasicView:function ()
Calendar:function (el, overrides)
Class:function Class()
CoordCache:function (options)
DayGrid:function ()
DayTableMixin:Object
DragListener:function (options)
EmitterMixin:Object
Grid:function (view)
ListenerMixin:Object
Model:function ()
MonthView:function ()
Promise:Object
RenderQueue:function (waitsByNamespace)
Scroller:function (options)
TaskQueue:function ()
TimeGrid:function ()
View:function (calendar, viewSpec)
applyAll:function applyAll(functions, thisObj, args)
capitaliseFirstLetter:function capitaliseFirstLetter(str)
compareByFieldSpec:function compareByFieldSpec(obj1, obj2, fieldSpec)
compareByFieldSpecs:function compareByFieldSpecs(obj1, obj2, fieldSpecs)
computeGreatestUnit:function computeGreatestUnit(start, end)
createObject:function createObject(proto)
cssToStr:function cssToStr(cssProps)
dataAttrPrefix:""
datepickerLocale:function (localeCode, dpLocaleCode, dpOptions)
debounce:function debounce(func, wait, immediate)
divideDurationByDuration:function divideDurationByDuration(dur1, dur2)
divideRangeByDuration:function divideRangeByDuration(start, end, dur)
durationHasTime:function durationHasTime(dur)
flexibleCompare:function flexibleCompare(a, b)
formatDate:function formatDate(date, formatStr)
formatRange:function formatRange(date1, date2, formatStr, separator, isRTL)
getClientRect:function getClientRect(el, origin)
getContentRect:function getContentRect(el, origin)
getOuterRect:function getOuterRect(el, origin)
getScrollbarWidths:function getScrollbarWidths(el)
htmlEscape:function htmlEscape(s)
internalApiVersion:9
intersectRanges:function intersectRanges(subjectRange, constraintRange)
intersectRects:function intersectRects(rect1, rect2)
isBgEvent:function isBgEvent(event)
isInt:function isInt(n)
locale:function (localeCode, newFcOptions)
locales:Object
log:function ()
moment:function ()
multiplyDuration:function multiplyDuration(dur, n)
oldMomentFormat:function oldMomentFormat(mom, formatStr)
parseFieldSpecs:function parseFieldSpecs(input)
pluckEventDateProps:function pluckEventDateProps(event)
preventDefault:function preventDefault(ev)
proxy:function proxy(obj, methodName)
queryMostGranularFormatUnit:function queryMostGranularFormatUnit(formatStr)
sourceFetchers:Array(0)
sourceNormalizers:Array(0)
touchMouseIgnoreWait:500
version:"3.4.0"
views:Object
warn:function ()
__proto__:Object
So I'm pretty sure that's right.
And what I get from console.log($('#calendar'))
is:
[div#calendar, context: document, selector: "#calendar"]
0:div#calendar
context:document
length:1
selector:"#calendar"
__proto__:Object(0)
That looks pretty good to me too.
I have no idea where I'm going wrong...
Edit:
The solution is to add the following to your plugins in webpack.config.js
:
new webpack.ProvidePlugin({
$: "jquery",
"window.jQuery": "jquery",
"moment": "moment"
})
I don't understand it but https://github.com/angular-ui/ui-calendar/issues/349#issuecomment-250865512 for further reading.
Upvotes: 1
Views: 1679
Reputation: 2118
I think that´s related to webpack configuration.
You should:
Upvotes: 1