Skip to content

Commit 9ef3227

Browse files
committed
make data, error and is-loading required but undefindable
1 parent 2c31023 commit 9ef3227

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/async-data/AsyncView.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,21 @@ type SuccessFunction<Data> = (data: Data) => ReactNode
66
type ErrorFunction<Error> = (error: NonNullable<Error>) => ReactNode
77

88
type Props<Data, Error> = {
9-
data?: Data
10-
error?: Error
11-
isLoading?: boolean
9+
/**
10+
* The async data to show.
11+
* Note that `error` and `isLoading` take precedence over data.
12+
*/
13+
data: Data | undefined
14+
/**
15+
* Set an error to show the error state.
16+
* Note that `isLoading` takes precedence over error.
17+
*/
18+
error: Error | undefined
19+
/**
20+
* Set to a boolean value to explicitly control loading state.
21+
* If undefined, loading state is shown when there is no data (null | undefined) and no error (null | undefined).
22+
*/
23+
isLoading: boolean | undefined
1224
renderLoading?: ReactNode | LoadingFunction
1325
renderError?: ReactNode | ErrorFunction<Error>
1426
} & (

0 commit comments

Comments
 (0)