fix(react): check if window exists
This commit is contained in:
@@ -28,6 +28,8 @@ export type FlowRendererProps<NodeType extends Node = Node> = Omit<
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
const win = typeof window === 'undefined' ? window : undefined;
|
||||
|
||||
const selector = (s: ReactFlowState) => {
|
||||
return { nodesSelectionActive: s.nodesSelectionActive, userSelectionActive: s.userSelectionActive };
|
||||
};
|
||||
@@ -70,8 +72,8 @@ function FlowRendererComponent<NodeType extends Node = Node>({
|
||||
isControlledViewport,
|
||||
}: FlowRendererProps<NodeType>) {
|
||||
const { nodesSelectionActive, userSelectionActive } = useStore(selector);
|
||||
const selectionKeyPressed = useKeyPress(selectionKeyCode, { target: window });
|
||||
const panActivationKeyPressed = useKeyPress(panActivationKeyCode, { target: window });
|
||||
const selectionKeyPressed = useKeyPress(selectionKeyCode, { target: win });
|
||||
const panActivationKeyPressed = useKeyPress(panActivationKeyCode, { target: win });
|
||||
|
||||
const panOnDrag = panActivationKeyPressed || _panOnDrag;
|
||||
const panOnScroll = panActivationKeyPressed || _panOnScroll;
|
||||
|
||||
Reference in New Issue
Block a user