Skip to content

Commit

Permalink
Merge pull request #41 from LePa-YU/testing
Browse files Browse the repository at this point in the history
find 'nodeId undefined' error
  • Loading branch information
NiharikaRajnish authored Oct 30, 2024
2 parents 227116a + e4252eb commit 9491e5d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/NetworkGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ const NetworkGraph = () => {
break;
case 'changeShape':
// Undo the shape change for a single node
const nodeToRevert = nodes.find(n => n.id === lastAction.payload.nodeId);
const nodeToRevert = nodes.find(n => n.id === lastAction.payload?.nodeId);
if (nodeToRevert) {
// Restore the original shape and color
nodeToRevert.shape = lastAction.payload.originalShape;
Expand All @@ -878,7 +878,7 @@ const NetworkGraph = () => {

case 'changeSize':
// Undo the size change for a single node
const nodeToRevert2 = nodes.find(n => n.id === lastAction.payload.nodeId);
const nodeToRevert2 = nodes.find(n => n.id === lastAction.payload?.nodeId);
if (nodeToRevert2) {
// Restore the original size
nodeToRevert2.size = lastAction.payload.originalSize;
Expand Down Expand Up @@ -946,8 +946,9 @@ const NetworkGraph = () => {
setHistory(prev => prev.slice(0, -1));
};
const handleRemoveNode = () => {
let nodeId = null;
if (selectedNode) {
const nodeId = selectedNode.id;
nodeId = selectedNode.id;
setNodes(nodes.filter(n => n.id !== nodeId));
setSelectedNode(null);
}
Expand Down

0 comments on commit 9491e5d

Please sign in to comment.