We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7086b38 commit bceb47dCopy full SHA for bceb47d
github-automated-repos-page/new/src/app/components/Sidebar/Sidebar.tsx
@@ -5,6 +5,9 @@ import { useEffect, useState } from "react";
5
import Link from "next/link";
6
import useCollapse from 'react-collapsed';
7
import { MdOutlineNavigateNext} from 'react-icons/md';
8
+
9
+const isBrowser = () => typeof window !== 'undefined';
10
11
export default function Sidebar() {
12
let url = window.location.pathname;
13
let parts = url.split('/');
@@ -23,11 +26,11 @@ export default function Sidebar() {
23
26
console.log(ScrollPercent)
24
27
};
25
28
- useEffect(() => {
29
+ if (isBrowser()) { //Only add the event listener client-side
30
window.addEventListener("scroll", onScroll)
- }, []);
31
+ }
32
33
-
34
return (
35
<aside className=" fixed min-w-[340px] h-full max-lg:hidden w-0">
36
0 commit comments