Type reusable async hook data generically.
Section: TypeScript Custom Hooks
Generic async hook result type
tsx
tsx
type AsyncResult<T> = {
data: T | null;
error: Error | null;
loading: boolean;
};Explanation
A reusable result type keeps async hook contracts consistent.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing TypeScript Custom Hooks
Typed tuple return
Return readonly tuples for hooks that act like useState.
Discriminated union reducer actions
Type reducer actions cleanly with a union.