From 8bc89d502fc8c70796d199b4f223d174e1f94ba0 Mon Sep 17 00:00:00 2001 From: shoofle Date: Wed, 18 Dec 2024 14:17:15 -0500 Subject: [PATCH] clicking on nodes in the graph is enabled --- client/src/landing/GraphRender.jsx | 34 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/client/src/landing/GraphRender.jsx b/client/src/landing/GraphRender.jsx index e0ce2cb2..30b0c70d 100644 --- a/client/src/landing/GraphRender.jsx +++ b/client/src/landing/GraphRender.jsx @@ -10,6 +10,21 @@ import { fetchGraph } from '../apiTools.jsx'; import ForceSupervisor from 'graphology-layout-force/worker'; +function GraphEvents() { + const navigate = useNavigate(); + const registerEvents = useRegisterEvents(); + + useEffect(() => { + // Register the events + registerEvents({ + // node events + clickNode: (event) => navigate(`/${event.node}`), + }); + }, [registerEvents]); + + return null; +} + export default function GraphRender() { const { isPending, error, data } = useQuery({ // fetch the currrent values queryKey: ['graph'], @@ -26,27 +41,14 @@ export default function GraphRender() { } }, [data]); - /* - const navigate = useNavigate(); - const registerEvents = useRegisterEvents(); - - useEffect(() => { - console.log("register events"); - // Register the events - registerEvents({ - // node events - clickNode: (event) => navigate(`/${event.node}`), - }); - }, [registerEvents]); - */ - if (isPending) return "Loading..."; else if (error) return `Error encountered: ${error}`; else return ( + style={{height: "400px", width: "100%", background: 'rgba(0,0,0,0)'}}> + + ); } \ No newline at end of file