useAgentState
Unpublished development API. This package is under development and is not available as a published release.
Observe the application state of an app-owned session. The component renders again only when the state changes, not on every streamed token.
The type comes from the session: a session created with a stateType yields
that type, read-only, and any other yields plain data. The value is
undefined until the session holds a state.
Pass select to read one part of the state. The component then renders again
only when the selected value changes. select runs once per state, so it may
build a new value without causing another render.
import { useAgentState } from '@threadplane/react';Declaration · overload 1
export declare function useAgentState<TState>(session: StateSession<TState>): TState | undefined;Type parameters
TState
Parameters
session· requiredStateSession<TState>
Returns
TState | undefinedDeclaration · overload 2
export declare function useAgentState<TState, TSelected>(session: StateSession<TState>, select: (state: TState | undefined) => TSelected): TSelected;Type parameters
TStateTSelected
Parameters
session· requiredStateSession<TState>select· required(state: TState | undefined) => TSelected
Returns
TSelected