Skip to content
Snippets Groups Projects
Commit c6d66c1c authored by Liliana Sanfilippo's avatar Liliana Sanfilippo
Browse files

fixed Warning: Invalid hook call. Hooks can only be called inside of the body...

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
parent ee26d452
No related branches found
No related tags found
No related merge requests found
Pipeline #407582 passed
......@@ -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
......@@ -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 (
<>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment