mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-15 05:14:55 -05:00
19 lines
588 B
TypeScript
19 lines
588 B
TypeScript
import { createSelector } from '@reduxjs/toolkit';
|
|
import { useAppSelector } from 'app/store/storeHooks';
|
|
import { selectFieldInputInstance, selectNodesSlice } from 'features/nodes/store/selectors';
|
|
import { useMemo } from 'react';
|
|
|
|
export const useInputFieldLabel = (nodeId: string, fieldName: string): string => {
|
|
const selector = useMemo(
|
|
() =>
|
|
createSelector(selectNodesSlice, (nodes) => {
|
|
return selectFieldInputInstance(nodes, nodeId, fieldName)?.label ?? '';
|
|
}),
|
|
[fieldName, nodeId]
|
|
);
|
|
|
|
const label = useAppSelector(selector);
|
|
|
|
return label;
|
|
};
|