Open abhisheksarka opened 1 year ago
Seems like everything is ok in your example, so my theory is that there are problems with redux. If you have not solved the problem yet, you can send a link to a sandbox.
what type is nodes?
if it is an array or object the dependency array will use referential comparison. so if you did not swap the object and instead just mutated it, the effect may not be running.
quick fix:
use [JSON.stringify(nodes)] in the dep array
I've got it working with a useRef
...
const engine = createEngine();
const model = useRef(new DiagramModel());
engine.setModel(model.current);
...
then when you need to interact with model
from a hook then you can:
model.current.addAll(node);
Hi,
I have been trying to make this work with useEffect as follows
Instead of useEffect if I call addNode function onClick of a button and then repaintCanvas, it works
Is anything extra required in case of useEffect? Thanks in advance!