You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Works with any async function, not just backend API calls
16
+
- Very good, native, Typescript support
17
+
- Small, no dependency
18
+
- Rules of hooks: ESLint find missing dependencies
8
19
- Refetch on params change
9
-
- Handle async callbacks (mutations)
10
-
- Handle concurrency issues if params change too fast
11
-
- Flexible, works with any async function, not just api calls
12
-
- Support for cancellation (AbortController)
13
-
- Possibility to trigger manual refetches / updates
20
+
- Can trigger manual refetch
14
21
- Options to customize state updates
15
-
- Very good, native, Typescript support
16
-
- Small and no dependency
22
+
- Can mutate state after fetch
23
+
24
+
25
+
**Things we don't support, by design**:
26
+
- stale-while-revalidate
27
+
- refetch on focus / resume
28
+
- caching
29
+
- polling
30
+
- request deduplication
31
+
- platform-specific code
32
+
- scroll position restoration
33
+
- SSR
34
+
- router integration for render-as-you-fetch pattern
35
+
36
+
You can indeed build on top of this little lib to provide more advanced features, if you like composition, that is encouraged in the React ecosystem.
37
+
38
+
If you prefer a full-featured fetching library, try [SWR](https://github.com/vercel/swr) or [React-Query](https://github.com/tannerlinsley/react-query).
39
+
17
40
18
41
## Usecase: loading async data into a component
19
42
@@ -82,7 +105,7 @@ or
82
105
83
106
`npm install react-async-hook --save`
84
107
85
-
# ESLint
108
+
##ESLint
86
109
87
110
If you use ESLint, use this [`react-hooks/exhaustive-deps`](https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/README.md#advanced-configuration) setting:
88
111
@@ -102,9 +125,6 @@ module.exports = {
102
125
}
103
126
```
104
127
105
-
# Warning
106
-
107
-
This library does not yet support React Suspense, but hopefully it will as soon as it can.
0 commit comments