We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8ffe055 commit bac802eCopy full SHA for bac802e
examples/basic-fetch/src/index.js
@@ -27,14 +27,20 @@ const UserDetails = ({ data }) => (
27
const App = () => (
28
<>
29
<Async promiseFn={loadUser} userId={1}>
30
- {({ data, isLoading }) => (isLoading ? <UserPlaceholder /> : <UserDetails data={data} />)}
+ {({ data, error, isLoading }) => {
31
+ if (isLoading) return <UserPlaceholder />
32
+ if (error) return <p>{error.message}</p>
33
+ if (data) return <UserDetails data={data} />
34
+ return null
35
+ }}
36
</Async>
37
38
<Async promiseFn={loadUser} userId={2}>
39
<Async.Loading>
40
<UserPlaceholder />
41
</Async.Loading>
42
<Async.Resolved>{data => <UserDetails data={data} />}</Async.Resolved>
43
+ <Async.Rejected>{error => <p>{error.message}</p>}</Async.Rejected>
44
45
</>
46
)
0 commit comments