Merge pull request #5629 from AlaricBaraou/fix-zustand-equality-check
Prevent re-render on every store update by using shallow in FlowRendererComponent useStore
This commit is contained in:
5
.changeset/curly-snails-do.md
Normal file
5
.changeset/curly-snails-do.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@xyflow/react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Prevent unnecessary re-render in `FlowRenderer`
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { memo, type ReactNode } from 'react';
|
import { memo, type ReactNode } from 'react';
|
||||||
|
import { shallow } from 'zustand/shallow';
|
||||||
|
|
||||||
import { useStore } from '../../hooks/useStore';
|
import { useStore } from '../../hooks/useStore';
|
||||||
import { useGlobalKeyHandler } from '../../hooks/useGlobalKeyHandler';
|
import { useGlobalKeyHandler } from '../../hooks/useGlobalKeyHandler';
|
||||||
@@ -72,7 +73,7 @@ function FlowRendererComponent<NodeType extends Node = Node>({
|
|||||||
onViewportChange,
|
onViewportChange,
|
||||||
isControlledViewport,
|
isControlledViewport,
|
||||||
}: FlowRendererProps<NodeType>) {
|
}: FlowRendererProps<NodeType>) {
|
||||||
const { nodesSelectionActive, userSelectionActive } = useStore(selector);
|
const { nodesSelectionActive, userSelectionActive } = useStore(selector, shallow);
|
||||||
const selectionKeyPressed = useKeyPress(selectionKeyCode, { target: win });
|
const selectionKeyPressed = useKeyPress(selectionKeyCode, { target: win });
|
||||||
const panActivationKeyPressed = useKeyPress(panActivationKeyCode, { target: win });
|
const panActivationKeyPressed = useKeyPress(panActivationKeyCode, { target: win });
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user