Skip to main content

PromiseState

The state shape that query atoms and injectPromise use. This shape is based off React Query's queries.

Definition

interface PromiseState<T> {
data?: T
error?: Error
isError: boolean
isLoading: boolean
isSuccess: boolean
status: PromiseStatus
}

type PromiseStatus = 'error' | 'loading' | 'success'
data

The promise's resolved value when the promise completes. undefined until then.

error

The promise's rejection value if the promise errors. undefined until then.

isError

A boolean. An alias for state.status === 'error'. Is set to true if the promise rejects.

isLoading

A boolean. An alias for state.status === 'loading'. true initially. Is set to false when the promise is fulfilled (resolved or rejected).

isSuccess

A boolean. An alias for state.status === 'success'. Is set to true when the promise resolves.

status

A string. One of 'error', 'loading', or 'success', reflecting the promise's current in-flight status.

See Also