[SOLVED] 4.0 to 5.2 migration -- TypeError: Cannot set property 'id' of undefined when invoking gantt.init(/*host_id*/)

I’ve been in the process of migrating from 4.0 to 5.2. I’m working in a React environment and have dhtmlx gantt wrapped in a React component.

For some reason, whenever I invoke gantt.init(/*host_id*/), I’m getting the following TypeError:

from TypeError: Cannot set property 'id' of undefined

I wasn’t getting this error with 4.0. Has anyone encountered this issue before?



For anyone else facing this issue, it’s because layout config was added to dhtmlx in 5.0. Without having a layout defined gantt will fail on init.

If you want to reinitialize Gantt, you need to specify the ID. It is true that the layout config was added in 5.x version. But Gantt should work correctly after gantt.init() command, if you specify the element correctly. Here is the demo:
You can install 5.x version there:
Then try reinitializing Gantt using this command: