DHTMLX / react-scheduler-demo

Simple Event Calendar component for React
17 stars 15 forks source link

[Question] Error in functional component implementation #18

Open jaballogian opened 2 years ago

jaballogian commented 2 years ago

Hello,

I'm trying to recreate this https://github.com/DHTMLX/react-scheduler-demo demo using the functional component instead of the class-based component here https://codesandbox.io/s/learn-dhx-scheduler-04r17f.

But there is an error with the scheduler below.

TypeError
this.$container.setAttribute is not a function

image

What's the source of the error and what's the solution to use the DHTMLX Scheduler component with functional component properly?

aryanisml commented 2 years ago

scheduleRef is null; you cant set the value in null div. try this one

//const schedulerRef = useRef(); const schedulerRef = useCallback((node) => { if (node !== null) { console.log(node); scheduler.init(node, new Date(2020, 5, 10)); scheduler.clearAll(); scheduler.parse(events);

  scheduler.render();

  setHoursScaleFormat(timeFormatState);
  //setHeight(node.getBoundingClientRect().height);
}

}, []);

Try this one https://codesandbox.io/s/learn-dhx-scheduler-demo-forked-eehe3r?file=/src/components/Scheduler/Scheduler.jsx