performance
This commit is contained in:
@@ -1,3 +1,21 @@
|
||||
/**
|
||||
* Use as second argument to React.memo() for node components.
|
||||
* Skips re-render when only position (or other unrelated props) changed,
|
||||
* so dragging one node doesn't force other nodes to re-render.
|
||||
*/
|
||||
export function nodePropsAreEqual<P extends { id?: string; data?: any; width?: number; height?: number; selected?: boolean }>(
|
||||
prev: P,
|
||||
next: P
|
||||
): boolean {
|
||||
return (
|
||||
prev.id === next.id &&
|
||||
prev.data === next.data &&
|
||||
prev.width === next.width &&
|
||||
prev.height === next.height &&
|
||||
prev.selected === next.selected
|
||||
)
|
||||
}
|
||||
|
||||
export const PREFIX_BY_TYPE: Record<string, string> = {
|
||||
config: 'cfg_',
|
||||
render: 'rnd_',
|
||||
|
||||
Reference in New Issue
Block a user