fix(react): check if window exists

This commit is contained in:
moklick
2024-06-20 15:47:01 +02:00
parent b2b4d5121d
commit 6704e51d2a
2 changed files with 6 additions and 3 deletions
@@ -9,6 +9,7 @@ import { Edge, Node } from '../types';
const selected = (item: Node | Edge) => item.selected;
const deleteKeyOptions: UseKeyPressOptions = { actInsideInputWithModifier: false };
const win = typeof window === 'undefined' ? window : undefined;
/**
* Hook for handling global key events.
@@ -26,7 +27,7 @@ export function useGlobalKeyHandler({
const { deleteElements } = useReactFlow();
const deleteKeyPressed = useKeyPress(deleteKeyCode, deleteKeyOptions);
const multiSelectionKeyPressed = useKeyPress(multiSelectionKeyCode, { target: window });
const multiSelectionKeyPressed = useKeyPress(multiSelectionKeyCode, { target: win });
useEffect(() => {
if (deleteKeyPressed) {