Skip to content

Commit f2cf465

Browse files
authored
Update README.md
1 parent 0fcaa5e commit f2cf465

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

README.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,40 @@
33
[![NPM](https://img.shields.io/npm/dm/react-async-hook.svg)](https://www.npmjs.com/package/react-async-hook)
44
[![Build Status](https://travis-ci.com/slorber/react-async-hook.svg?branch=master)](https://travis-ci.com/slorber/react-async-hook)
55

6-
- Simplest way to get async result / feedback in your React component
7-
- Works with any React platform (ReactNative, Expo...)
6+
This library only **do one small thing**, and **do it well**.
7+
8+
Don't expect it to grow in size, because it is **feature complete**:
9+
10+
- Handle fetches (`useAsync`)
11+
- Handle mutations (`useAsyncCallback`)
12+
- Handle cancellation (`useAsyncAbortable` + `AbortController`)
13+
- Handle race conditions
14+
- Platform agnostic
15+
- 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
819
- 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
1421
- 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+
1740

1841
## Usecase: loading async data into a component
1942

@@ -82,7 +105,7 @@ or
82105

83106
`npm install react-async-hook --save`
84107

85-
# ESLint
108+
## ESLint
86109

87110
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:
88111

@@ -102,9 +125,6 @@ module.exports = {
102125
}
103126
```
104127

105-
# Warning
106-
107-
This library does not yet support React Suspense, but hopefully it will as soon as it can.
108128

109129
# FAQ
110130

0 commit comments

Comments
 (0)