Cloud API Overview > @adpt/cloud > k8s > useResource
k8s.useResource() function
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Hook to allow conversion of a prop that could be a value or a handle
This function behaves similarly to k8s.useResources(), but works for a prop that is either a Handle or a single value instead of an array of Handles and values.
See k8s.useResources() for more detailed documentation.
Signature:
export declare function useResource<ValT, NotReadyT>(opts: {
initial: ValT | NotReadyT;
notReady: NotReadyT;
kinds: string[];
thisResourceName: string;
propName: string;
}): [
ValT | NotReadyT,
(prop: ValT | Handle, f: (e: AdaptMountedElement, props: ResourceProps) => Promise<ValT> | ValT) => void
];
Parameters
Parameter | Type | Description |
---|---|---|
opts | { initial: ValT | NotReadyT; notReady: NotReadyT; kinds: string[]; thisResourceName: string; propName: string; } |
Returns:
[ ValT | NotReadyT, (prop: ValT | Handle, f: (e: AdaptMountedElement, props: ResourceProps) => Promise<ValT> | ValT) => void ]