Skip to content

Commit c4c5e76

Browse files
committed
small ref
1 parent 17f1a65 commit c4c5e76

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/expandable.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ export function Expandable({title, level, children, permalink}: Props) {
2626

2727
// Ensure we scroll to the element if the URL hash matches
2828
useEffect(() => {
29-
if (id && window.location.hash === `#${id}`) {
29+
if (!id) {
30+
return () => {};
31+
}
32+
33+
if (window.location.hash === `#${id}`) {
3034
document.querySelector(`#${id}`)?.scrollIntoView();
3135
setIsExpanded(true);
3236
}

0 commit comments

Comments
 (0)