Skip to content

Function: useComputedItems()

ts
function useComputedItems<T>(
   items: 
  | T[]
  | (params: {
  data: Record<string, unknown>;
  value: any;
}) => T[] | Promise<T[]>
  | undefined, 
   state: Record<string, unknown>, 
   stateValue: any): T[] | undefined;

Defined in: src/UI/hooks/useComputedItems.ts:14

Hook to compute items from either a static array or a dynamic function. Prevents infinite render loops by:

  1. Storing the items function in a ref (avoids re-triggers on function reference changes)
  2. Using JSON.stringify signatures for stable dependencies (only re-evaluates when data actually changes)

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
items| T[] | (params: { data: Record<string, unknown>; value: any; }) => T[] | Promise<T[]> | undefinedStatic array or function that returns array of items
stateRecord<string, unknown>The global UI state object
stateValueanyThe current field value (derived from state[name])

Returns

T[] | undefined

The computed items array or undefined

Matterway Assistant SDK Documentation