[React] setState inside afterCreateRow hook fires error without setTimeout

Tags: #<Tag:0x00007efc6debf878> #<Tag:0x00007efc6debf620>

Hello,

I’m trying to set the source data after adding a row with afterCreateRow hook.
However, the console gives me below error if I do not use setTimeout to wrap the code with setState.
Could you please guide me the correct way to set the data after the afterCreateRow hook?

Uncaught TypeError: Cannot set properties of null (setting ‘forceFullRender’)

https://jsfiddle.net/x6Lj1h4b/11/

Steps to reproduce is to insert row with the context menu, the error appears in the console.
And then remove the comment on line 20, 26 then insert row, the error does not appear.

Hi @hjeong1200

Thank you for contacting us. In some cases logic executed within afterCreateRow hook might be desynchronized between instance initialization and the code called in the hook and that might cause errors. Then we recommend to use timeout to delay the execution of the code a little bit.

Hello @adrian.szymanski

Thank you for the clarification!
I just have one more question. With the same jsfiddle, is setData a valid way to update the source data? I have read the below react-handsontable document which covers loadData and updateData functions but visually the three methods all seem to produce same outcome.