Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

try useEffect instead 🤢

Steven Tey0f547beb33d5
diff --git a/apps/web/ui/layout/sidebar/sidebar-nav.tsx b/apps/web/ui/layout/sidebar/sidebar-nav.tsx
index afcc0f6e37..087b00213f 100644
--- a/apps/web/ui/layout/sidebar/sidebar-nav.tsx
+++ b/apps/web/ui/layout/sidebar/sidebar-nav.tsx
@@ -8,6 +8,7 @@ import {
PropsWithChildren,
ReactNode,
Suspense,
+ useEffect,
useMemo,
useState,
} from "react";
@@ -99,10 +100,14 @@ export function SidebarNav({ toolContent }: { toolContent?: ReactNode }) {
function NavItem({ item }: { item: NavItemType }) {
const { name, icon: Icon, href, exact } = item;
+ const [hovered, setHovered] = useState(false);
+ const [isActive, setIsActive] = useState(false);
+
const pathname = usePathname();
- const isActive = exact ? pathname === href : pathname.startsWith(href);
- const [hovered, setHovered] = useState(false);
+ useEffect(() => {
+ setIsActive(exact ? pathname === href : pathname.startsWith(href));
+ }, [exact, pathname, href]);
return (
<Link