#Undo event
1 messages · Page 1 of 1 (latest)
If you can get reactflow pro and want a proper undo/redo solution, you can use this Undo Redo Example
Hmn. At the end of the day, you still have to mutate the whole nodes or edges array state when you undo or redo.
What is the actual problem you are facing when you add the node or edge back to the array state on undoing a delete action? You said it throws undefined value. I didnt get it?
You are storing the node object in some history stack when you delete a node(use the filter method to remove that node from the nodes state) and then when you undo you add that node object back to the nodes array state?
Can you share the undo function? Also the function in which you update your history stack when you delete a node?
Kindly share the setUndoAction function as well
In the handleUndo function, you are calling the setUndoAction function in case of DELETE. I am asking you to share its code
case "DELETE_NODE":
if (actionHistory.nodeData && actionHistory.edgeData) {
setUndoAction(); // <--- THIS ONE
} else {
console.error("actionHistory nodeData or edgeData is not found.");
}
break;
In this function, why arent you adding the node and edges you saved, back into the nodes and edges state?