Skip to content

Commit 0afe61d

Browse files
committed
safely use sidebar
1 parent d49828a commit 0afe61d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/components/DocsCategoryDropdown/index.jsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,18 @@ function DocsCategoryDropdown({ dropdownCategory }) {
4747
}
4848
}, [isOpen]); // This runs when the dropdown is opened
4949

50-
const sidebar = useDocsSidebar();
51-
const isSelected = sidebar && sidebar.name && dropdownCategory ? sidebar.name === dropdownCategory.sidebar : false;
50+
let sidebar = null;
51+
52+
// Safely call useDocsSidebar
53+
try {
54+
sidebar = useDocsSidebar();
55+
} catch (e) {
56+
}
57+
58+
// Guard against undefined sidebar
59+
const isSelected = sidebar && sidebar.name && dropdownCategory
60+
? sidebar.name === dropdownCategory.sidebar
61+
: false;
5262

5363
return (
5464
<div

0 commit comments

Comments
 (0)