From 7bfa18f506bf89e972e2f9529c5b69352946acd7 Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 27 Jul 2020 20:14:48 +0200 Subject: [PATCH] Bugfix: Update onConnect Will call setOnConnect if function passed as onConnect changes --- src/container/GraphView/index.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/container/GraphView/index.tsx b/src/container/GraphView/index.tsx index b8503fc7..18ad2ed7 100644 --- a/src/container/GraphView/index.tsx +++ b/src/container/GraphView/index.tsx @@ -142,10 +142,6 @@ const GraphView = memo( updateDimensions(); window.onresize = updateDimensions; - if (onConnect) { - setOnConnect(onConnect); - } - if (rendererNode.current) { resizeObserver = new ResizeObserver((entries) => { for (let _ of entries) { @@ -201,6 +197,12 @@ const GraphView = memo( } }, [d3Initialised, onLoad]); + useEffect(() => { + if (onConnect) { + setOnConnect(onConnect); + } + }, [onConnect]); + useEffect(() => { setSnapGrid({ snapToGrid, snapGrid }); }, [snapToGrid]);