Hook Data Type Reference

The HookData type represents the non-null data from a BAML React hook. This type is useful when you know the data exists and want to avoid undefined checks.

1function Component() {
2 const hook = useTestAws({
3 stream: true, // optional, defaults to true
4 })
5
6 const data = hook.data;
7
8 return (
9 <div>
10 {data} {/* No need for null checks */}
11 </div>
12 )
13}

Type Parameters

FunctionName
generic

The name of the BAML function being called. Used to infer input and output types.

Options
{ stream?: boolean }

Configuration object that determines streaming behavior. Defaults to { stream?: true }.

Type Details

type
NonNullable<HookOutput<FunctionName, Options>['data']>

A utility type that removes undefined from the data property of HookOutput. This means the type will be either FinalDataType or StreamDataType depending on the streaming configuration.