diff --git a/app/components/PathBar.tsx b/app/components/PathBar.tsx
index 8437649..c8dd890 100644
--- a/app/components/PathBar.tsx
+++ b/app/components/PathBar.tsx
@@ -10,6 +10,7 @@ import {
useJsonColumnViewState,
} from "../hooks/useJsonColumnView";
import { useHotkeys } from "react-hotkeys-hook";
+import { memo } from "react";
export function PathBar() {
const { selectedNodes, highlightedNodeId } = useJsonColumnViewState();
@@ -37,34 +38,13 @@ export function PathBarLink({
{selectedNodes.map((node, index) => {
return (
-
-
goToNodeId(node.id)}
- >
-
- {node.icon && }
-
-
- {node.title}
-
-
-
- {index == selectedNodes.length - 1 ? (
- <>>
- ) : (
-
- )}
-
+
);
})}
@@ -110,3 +90,59 @@ export function PathHistoryControls() {
);
}
+
+function PathBarElement({
+ node,
+ highlightedNodeId,
+ goToNodeId,
+ isLast,
+}: {
+ node: ColumnViewNode;
+ highlightedNodeId: string | undefined;
+ goToNodeId: (id: string) => void;
+ isLast: boolean;
+}) {
+ return (
+
+
goToNodeId(node.id)}
+ >
+
+ {node.icon && }
+
+
+ {node.title}
+
+
+
+ {isLast ? (
+ <>>
+ ) : (
+
+ )}
+
+ );
+}
+
+const PathBarItem = memo(PathBarElement, (oldProps, newProps) => {
+ if (oldProps.node.id !== newProps.node.id) return false;
+ if (oldProps.highlightedNodeId !== newProps.highlightedNodeId) {
+ const wasHighlighted = oldProps.highlightedNodeId == oldProps.node.id;
+ const nowHighlighted = newProps.highlightedNodeId == newProps.node.id;
+ if (wasHighlighted !== nowHighlighted) return false;
+ }
+ return true;
+});