mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-15 18:44:56 -05:00
- Optimize component and hook structure for input fields to reduce rerenders of component tree - Remove memoization on some selectors where it serves no purpose (bc the object will have a stable identity until it changes, at which point we need to re-render anyways) - Shift the connection error selector logic around to rely more on the stable identity of pending connection objects
20 lines
600 B
TypeScript
20 lines
600 B
TypeScript
import { createSelector } from '@reduxjs/toolkit';
|
|
import { useAppSelector } from 'app/store/storeHooks';
|
|
import { selectNodeData, selectNodesSlice } from 'features/nodes/store/selectors';
|
|
import type { InvocationNodeData } from 'features/nodes/types/invocation';
|
|
import { useMemo } from 'react';
|
|
|
|
export const useNodeData = (nodeId: string): InvocationNodeData => {
|
|
const selector = useMemo(
|
|
() =>
|
|
createSelector(selectNodesSlice, (nodes) => {
|
|
return selectNodeData(nodes, nodeId);
|
|
}),
|
|
[nodeId]
|
|
);
|
|
|
|
const nodeData = useAppSelector(selector);
|
|
|
|
return nodeData;
|
|
};
|