From c6d66c1c1ff70f0e1d58c0cf13a0c28a95d4c65e Mon Sep 17 00:00:00 2001
From: liliana <liliana.sanfilippo@uni-bielefeld.de>
Date: Fri, 23 Aug 2024 21:07:50 +0200
Subject: [PATCH] fixed Warning: Invalid hook call. Hooks can only be called
 inside of the body of a function component. This could happen for one of the
 following reasons: 1. You might have mismatching versions of React and the
 renderer (such as React DOM) 2. You might be breaking the Rules of Hooks 3.
 You might have more than one copy of React in the same app See
 https://reactjs.org/link/invalid-hook-call for tips about how to debug and
 fix this problem. react.development.js:209:29     React 4     useNavigate
 hooks.tsx:182     <anonymous> goto.tsx:53

---
 src/components/goto.tsx |  6 ++++--
 src/contents/wiki.tsx   | 44 ++++++++++++++++++++---------------------
 2 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/src/components/goto.tsx b/src/components/goto.tsx
index b7ea687c..5eb41f11 100644
--- a/src/components/goto.tsx
+++ b/src/components/goto.tsx
@@ -50,10 +50,12 @@ export const SupScrollLink : React.FC<SupScrollLinkProps> = ({label }) => {
         </sup> 
     );
 };
-const navigate = useNavigate();
+
 export const goToTextsAndOpenCollapsible = (collapseId: string) => {
+    const navigate = useNavigate();
     navigate(collapseId);
 };
 export const goToPagesAndOpenTab = (tabId: string) => {
-navigate(tabId);
+    const navigate = useNavigate();
+    navigate(tabId);
 };
\ No newline at end of file
diff --git a/src/contents/wiki.tsx b/src/contents/wiki.tsx
index 79312d8f..b4c2037f 100644
--- a/src/contents/wiki.tsx
+++ b/src/contents/wiki.tsx
@@ -8,31 +8,31 @@ import React from "react";
 export function Wiki  () {
   const location = useLocation();
 
-    useEffect(() => {
-        const params = new URLSearchParams(location.search);
-        const collapseId = params.get('collapseId');
-        const tabId = params.get('tab');
+  useEffect(() => {
+    const params = new URLSearchParams(location.search);
+    const collapseId = params.get('collapseId');
+    const tabId = params.get('tab');
 
-        // Scroll to the section specified by collapseId
-        if (collapseId) {
-            const collapseElement = document.getElementById(collapseId);
-            if (collapseElement) {
-                const elementTop = collapseElement.getBoundingClientRect().top + window.pageYOffset;
-                const offset = window.innerHeight / 2 - collapseElement.offsetHeight / 2;
-                const scrollPosition = elementTop - offset;
+    // Handle scroll to collapse section
+    if (collapseId) {
+      const collapseElement = document.getElementById(collapseId);
+      if (collapseElement) {
+        const elementTop = collapseElement.getBoundingClientRect().top + window.pageYOffset;
+        const offset = window.innerHeight / 2 - collapseElement.offsetHeight / 2;
+        const scrollPosition = elementTop - offset;
 
-                window.scrollTo({
-                    top: scrollPosition,
-                    behavior: 'smooth',
-                });
-            }
-        }
+        window.scrollTo({
+          top: scrollPosition,
+          behavior: 'smooth',
+        });
+      }
+    }
 
-        // Open the tab specified by tabId
-        if (tabId) {
-            openFromOtherPage(tabId)({ currentTarget: document.getElementById(tabId)! });
-        }
-    }, [location.search]);
+    // Handle opening the tab
+    if (tabId) {
+      openFromOtherPage(tabId)({ currentTarget: document.getElementById(tabId)! });
+    }
+  }, [location.search]);
 
   return (
        <>
-- 
GitLab