From b3c1b737e7a52bef96e7170c174cbbeb4d7f623d Mon Sep 17 00:00:00 2001
From: "Thomas F. K. Jorna" <thomasfkjorna@gmail.com>
Date: Thu, 22 Jul 2021 21:43:08 +0200
Subject: fix moving around when hovering in local mode

---
 pages/index.tsx | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

(limited to 'pages/index.tsx')

diff --git a/pages/index.tsx b/pages/index.tsx
index 06c7dc2..e5679f2 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -1,4 +1,4 @@
-import React, { ComponentPropsWithoutRef, useEffect, useRef, useState } from 'react'
+import React, { ComponentPropsWithoutRef, useEffect, useRef, useState, useMemo } from 'react'
 import { usePersistantState } from '../util/persistant-state'
 const d3promise = import('d3-force-3d')
 
@@ -489,7 +489,10 @@ export const Tweaks = function (props: TweakProps) {
                   onChange={(value) => setPhysics({ ...physics, highlightNodeSize: value })}
                 />
                 <Flex justifyContent="space-between">
-                  <Text></Text>
+                  <Text> Highlight node color </Text>
+                </Flex>
+                <Flex justifyContent="space-between">
+                  <Text> Highlight link color </Text>
                 </Flex>
               </EnableSection>
             </VStack>
@@ -606,13 +609,16 @@ export const Graph = function (props: GraphProps) {
     return scopedNodeIds.includes(sourceId as string) && scopedNodeIds.includes(targetId as string)
   })
 
-  const scopedGraphData =
-    scope.nodeIds.length === 0
-      ? graphData
-      : {
-          nodes: scopedNodes,
-          links: scopedLinks,
-        }
+  const scopedGraphData = useMemo(
+    () =>
+      scope.nodeIds.length === 0
+        ? graphData
+        : {
+            nodes: scopedNodes,
+            links: scopedLinks,
+          },
+    [scope],
+  )
 
   useEffect(() => {
     ;(async () => {
-- 
cgit v1.2.3

