From bcb96a84b6fd9457db701e69e2b379a7f0b93598 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 8 Oct 2024 14:25:50 +0200 Subject: [PATCH] fix: Breadcrumbs improvements (#654) --- src/components/Breadcrumbs.tsx | 8 +++++--- src/hooks/useResizeObserver.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/Breadcrumbs.tsx b/src/components/Breadcrumbs.tsx index 421587c6..3eb37779 100644 --- a/src/components/Breadcrumbs.tsx +++ b/src/components/Breadcrumbs.tsx @@ -341,9 +341,11 @@ export function DynamicBreadcrumbs({ const refitCrumbList = useCallback( ({ width: wrapperWidth }: { width: number }) => { - const lists = Array.from( - wrapperRef?.current?.querySelectorAll(`[${CRUMB_LIST_ATTR}]`) - ) + const lists = wrapperRef?.current + ? Array.from( + wrapperRef.current.querySelectorAll(`[${CRUMB_LIST_ATTR}]`) + ) + : [] const { id } = lists.reduce( (prev, next) => { const prevWidth = prev.width diff --git a/src/hooks/useResizeObserver.ts b/src/hooks/useResizeObserver.ts index bd194300..574eb6cf 100644 --- a/src/hooks/useResizeObserver.ts +++ b/src/hooks/useResizeObserver.ts @@ -33,7 +33,7 @@ const useResizeObserver = ( RO.observe(ref.current) return () => { - RO.disconnect() + RO?.disconnect() RO = null } }, [ref, handleResize])