However, after any task store event both flags, stm.canUndo and stm.canRedo, always return false.
But when we output the stm in the dev console canUndo is true after a change event as it should be.
How can we subscribe to task store events in such a fashion that our useState() is set correctly?
Thanks for the detailed case, do you have some special configuration set in the Gantt configuration?? In the useEffect code that you shared, you only set in the component state the current state of the stm.
Could you please provide a complete example with your case?? You can check the guidelines here viewtopic.php?f=1&t=772
Thanks for the sample project and the detailed step-by-step to reproduce. Checking the code, you need to check the STM of the project (that's the one that you enabled in the config), also, the console.log issue is because STM transactions are asynchronous, so when you console them, they aren't finished, so the undo is still false, then after checking the dev console, it displays true. I updated the useEffect to work as you described/coded.