Skip to content

Commit 6befdea

Browse files
authored
Update README.md
1 parent 83b78af commit 6befdea

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

README.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# react-async
1+
# <Async>
22

3-
React component for declarative promise resolution and data fetching. Uses render props for full flexibility or Context
4-
for convenience. Makes no assumptions about the shape of your data, the type of request or how you deal with loading
5-
states and errors. Supports optimistic updates.
3+
React component for declarative promise resolution and data fetching. Uses render props for full flexibility or React context
4+
for convenience. Makes it easy to handle loading and error states, without assumptions about the shape of your data or the type of request. Supports optimistic updates.
65

76
## Install
87

@@ -68,26 +67,26 @@ const MyComponent = () => {
6867

6968
`<Async>` takes the following properties:
7069

71-
- `promiseFn` [() => Promise] A function that returns a promise; invoked immediately in `componentDidMount` and without arguments
72-
- `deferFn` [() => Promise] A function that returns a promise; invoked only by calling `run`, with arguments being passed through
73-
- `watch` [any] Watches this property through `componentDidUpdate` and re-runs the `promiseFn` when the value changes (`oldValue !== newValue`)
74-
- `onResolve` [Function] Callback function invoked when a promise resolves, receives data as argument
75-
- `onReject` [Function] Callback function invoked when a promise rejects, receives error as argument
70+
- `promiseFn` {() => Promise} A function that returns a promise; invoked immediately in `componentDidMount` and without arguments
71+
- `deferFn` {() => Promise} A function that returns a promise; invoked only by calling `run`, with arguments being passed through
72+
- `watch` {any} Watches this property through `componentDidUpdate` and re-runs the `promiseFn` when the value changes (`oldValue !== newValue`)
73+
- `onResolve` {Function} Callback function invoked when a promise resolves, receives data as argument
74+
- `onReject` {Function} Callback function invoked when a promise rejects, receives error as argument
7675

7776
### Render props
7877

7978
`<Async>` provides the following render props:
8079

81-
- `data` [any] last resolved promise value, maintained when new error arrives
82-
- `error` [Error] rejected promise reason, cleared when new data arrives
83-
- `isLoading` [boolean] `true` while a promise is pending
84-
- `startedAt` [Date] when the current/last promise was started
85-
- `finishedAt` [Date] when the last promise was resolved or rejected
86-
- `cancel` [Function] ignores the result of the currently pending promise
87-
- `run` [Function] runs the `deferFn`, passing any arguments provided
88-
- `reload` [Function] re-runs the promise when invoked, using the previous arguments
89-
- `setData` [Function] sets `data` to the passed value, unsets `error` and cancels any pending promise
90-
- `setError` [Function] sets `error` to the passed value and cancels any pending promise
80+
- `data` {any} last resolved promise value, maintained when new error arrives
81+
- `error` {Error} rejected promise reason, cleared when new data arrives
82+
- `isLoading` {boolean} `true` while a promise is pending
83+
- `startedAt` {Date} when the current/last promise was started
84+
- `finishedAt` {Date} when the last promise was resolved or rejected
85+
- `cancel` {Function} ignores the result of the currently pending promise
86+
- `run` {Function} runs the `deferFn`, passing any arguments provided
87+
- `reload` {Function} re-runs the promise when invoked, using the previous arguments
88+
- `setData` {Function} sets `data` to the passed value, unsets `error` and cancels any pending promise
89+
- `setError` {Function} sets `error` to the passed value and cancels any pending promise
9190

9291
## Examples
9392

0 commit comments

Comments
 (0)