From 2456047dd1b93742e11929b6123053a8f325059a Mon Sep 17 00:00:00 2001 From: Piotr Monwid-Olechnowicz Date: Sun, 16 Nov 2025 16:57:18 +0100 Subject: [PATCH] Add apparently redundant optional chaining --- src/components/sidebar/index.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/sidebar/index.tsx b/src/components/sidebar/index.tsx index a9acb96326..2d4733bf0c 100644 --- a/src/components/sidebar/index.tsx +++ b/src/components/sidebar/index.tsx @@ -22,7 +22,12 @@ import { useState, } from "react" import scrollIntoView from "scroll-into-view-if-needed" -import { useActiveAnchor, useThemeConfig, Collapse } from "nextra-theme-docs" +import { + useActiveAnchor, + useThemeConfig, + Collapse, + ActiveAnchor, +} from "nextra-theme-docs" import ArrowBarLeft from "@/app/conf/_design-system/pixelarticons/arrow-bar-left.svg?svgr" import { Anchor } from "@/app/conf/_design-system/anchor" @@ -249,7 +254,11 @@ function File({ // It is possible that the item doesn't have any route - for example an external link. const active = item.route && [route, route + "/"].includes(item.route + "/") - const activeAnchor = useActiveAnchor() + /** + * we don't have this bug in staging, but this crashed in prod + * todo: clear this up when we investigate why that happened only in prod + */ + const activeAnchor = useActiveAnchor() as ActiveAnchor | null const { setMenu } = useMenu() if (item.type === "separator") { @@ -277,7 +286,7 @@ function File({ className={cn( classes.link, 'flex gap-2 before:opacity-25 before:content-["#"]', - activeAnchor[id]?.isActive + activeAnchor?.[id]?.isActive ? classes.active : classes.inactive, )}