diff --git a/beta/src/components/MDX/Sandpack/NavigationBar.tsx b/beta/src/components/MDX/Sandpack/NavigationBar.tsx index 922982d6..ff7ac23d 100644 --- a/beta/src/components/MDX/Sandpack/NavigationBar.tsx +++ b/beta/src/components/MDX/Sandpack/NavigationBar.tsx @@ -53,7 +53,11 @@ export function NavigationBar({providedFiles}: {providedFiles: Array}) { hasJustToggledDropdown.current = false; return; } - const tabsWidth = tabsRef.current!.getBoundingClientRect().width; + if (tabsRef.current === null) { + // Some ResizeObserver calls come after unmount. + return; + } + const tabsWidth = tabsRef.current.getBoundingClientRect().width; const needsDropdown = tabsWidth >= containerWidth; if (needsDropdown !== showDropdown) { hasJustToggledDropdown.current = true;