Skip to content

Commit 235df0c

Browse files
committed
Fix Node Enter/Exit Bug
1 parent 4794ce6 commit 235df0c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/contexts/nodeHistory.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ const createNodeHistoryContext = () => {
2626
nodeId: string,
2727
topLevel: boolean = false,
2828
) => {
29-
nodeHistory.current.push(activeNode);
30-
if (topLevel) nodeHistory.current = [];
31-
setActiveNode(nodeId);
32-
}, [activeNode]);
29+
setActiveNode(active => {
30+
nodeHistory.current.push(active);
31+
if (topLevel) nodeHistory.current = [];
32+
return nodeId;
33+
});
34+
}, []);
3335

3436
const closeNode = useCallback(() => {
3537
setActiveNode(nodeHistory.current.pop()!);

0 commit comments

Comments
 (0)