Skip to content

Commit 96dcbdf

Browse files
authored
fix: ReferenceError: window is not defined when using with SSR (#3929)
1 parent 6619f76 commit 96dcbdf

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.changeset/lazy-terms-hang.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphiql/react': patch
3+
---
4+
5+
fix: `ReferenceError: window is not defined` when using with SSR

packages/graphiql-react/src/utility/debounce.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ export function debounce<F extends (...args: any[]) => any>(
88
duration: number,
99
fn: F,
1010
) {
11-
let timeout: number | null;
11+
let timeout: ReturnType<typeof setTimeout> | null;
1212
return function (...args) {
1313
if (timeout) {
14-
window.clearTimeout(timeout);
14+
clearTimeout(timeout);
1515
}
16-
timeout = window.setTimeout(() => {
16+
timeout = setTimeout(() => {
1717
timeout = null;
1818
fn(...args);
1919
}, duration);

0 commit comments

Comments
 (0)