Skip to content

Commit afa35e7

Browse files
committed
Fix SSR error in Sidebar: use onMount cleanup for window access
1 parent 6c04009 commit afa35e7

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/lib/components/layout/Sidebar.svelte

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { onMount, onDestroy } from 'svelte';
2+
import { onMount } from 'svelte';
33
import { base } from '$app/paths';
44
import { page } from '$app/stores';
55
import { goto } from '$app/navigation';
@@ -33,10 +33,9 @@
3333
3434
onMount(() => {
3535
window.addEventListener('keydown', handleGlobalKeydown);
36-
});
37-
38-
onDestroy(() => {
39-
window.removeEventListener('keydown', handleGlobalKeydown);
36+
return () => {
37+
window.removeEventListener('keydown', handleGlobalKeydown);
38+
};
4039
});
4140
4241
// Check if we're on an API page or examples listing page

0 commit comments

Comments
 (0)