Skip to content

Commit 4e1856b

Browse files
committed
fix: check window exists in case called server side
1 parent 8189614 commit 4e1856b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/RightClickCancelSensor.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ export class RightClickCancelSensor extends PointerSensor {
1818

1919
constructor(props: PointerSensorProps) {
2020
super(props);
21-
window.addEventListener('contextmenu', this.handleContextMenu, {
22-
passive: false,
23-
});
21+
if (typeof window !== 'undefined') {
22+
window.addEventListener('contextmenu', this.handleContextMenu, {
23+
passive: false,
24+
});
25+
}
2426
}
2527

2628
teardown() {
27-
window.removeEventListener('contextmenu', this.handleContextMenu);
29+
if (typeof window !== 'undefined') {
30+
window.removeEventListener('contextmenu', this.handleContextMenu);
31+
}
2832
}
2933
}

0 commit comments

Comments
 (0)