Closed phoon0901 closed 5 years ago
Did you manage to solve this? I'm running into the same problem.
I think this will be due to the scheduleData object not been created in time before the component renders
Anyone know how to solve this?
Guys, any luck with this please? @duanshuyong0 @dandanknight @phoon0901
I encountered this issue, this was because schedulerData
was not correctly initialized in my class.
class MyPlanning extends React.Component {
schedulerData = undefined;
componentDidMount() {
this.schedulerData = new SchedulerData(/* ... */);
// [ ... ]
}
render() {
return (
<Scheduler
schedulerData={this.schedulerData} // <- this.schedulerData is undefined.
prevClick={this.prevClick}
nextClick={this.nextClick}
onSelectDate={this.onSelectDate}
onViewChange={this.onViewChange}
eventItemClick={this.eventClicked}
/>
);
}
}
this.schedulerData
is undefined
at first render because componentDidMount()
is called after first render()
call.
So check schedulerData
before using it.
render() {
return this.schedulerData ? <Scheduler schedulerData={this.schedulerData} { ... } /> : null;
}
Hope this helps.
I tried to follow your demo . However, I received an error TypeError: Cannot read property '_setDocumentWidth' of undefined at index.js in line 173.
schedulerData._setDocumentWidth(document.documentElement.clientWidth);
Anyone know how to solve this?