Skip to content

Commit 702a32f

Browse files
committed
Replace occurences of Async.Loading with Async.Pending and isLoading with isPending, since this is the preferred terminology.
1 parent d21d7df commit 702a32f

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

README.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Use it with `fetch`, Axios or other data fetching libraries, even GraphQL.
6767
- Works with promises, async/await and the Fetch API
6868
- Choose between Render Props, Context-based helper components or the `useAsync` and `useFetch` hooks
6969
- Debug and develop every part of the loading sequence with the [DevTools](#devtools)
70-
- Provides convenient `isLoading`, `startedAt`, `finishedAt`, et al metadata
70+
- Provides convenient `isPending`, `startedAt`, `finishedAt`, et al metadata
7171
- Provides `cancel` and `reload` actions
7272
- Automatic re-run using `watch` or `watchFn` prop
7373
- Accepts `onResolve`, `onReject` and `onCancel` callbacks
@@ -127,7 +127,7 @@ React Async is promise-based, so you can resolve anything you want, not just `fe
127127

128128
The React team is currently working on a large rewrite called [Concurrent React], previously known as "Async React".
129129
Part of this rewrite is Suspense, which is a generic way for components to suspend rendering while they load data from
130-
a cache. It can render a fallback UI while loading data, much like `<Async.Loading>`.
130+
a cache. It can render a fallback UI while loading data, much like `<Async.Pending>`.
131131

132132
React Async has no direct relation to Concurrent React. They are conceptually close, but not the same. React Async is
133133
meant to make dealing with asynchronous business logic easier. Concurrent React will make those features have less
@@ -232,8 +232,8 @@ const loadCustomer = async ({ customerId }, { signal }) => {
232232
}
233233

234234
const MyComponent = () => {
235-
const { data, error, isLoading } = useAsync({ promiseFn: loadCustomer, customerId: 1 })
236-
if (isLoading) return "Loading..."
235+
const { data, error, isPending } = useAsync({ promiseFn: loadCustomer, customerId: 1 })
236+
if (isPending) return "Loading..."
237237
if (error) return `Something went wrong: ${error.message}`
238238
if (data)
239239
return (
@@ -253,7 +253,7 @@ Or using the shorthand version:
253253

254254
```jsx
255255
const MyComponent = () => {
256-
const { data, error, isLoading } = useAsync(loadCustomer, options)
256+
const { data, error, isPending } = useAsync(loadCustomer, options)
257257
// ...
258258
}
259259
```
@@ -267,7 +267,7 @@ import { useFetch } from "react-async"
267267

268268
const MyComponent = () => {
269269
const headers = { Accept: "application/json" }
270-
const { data, error, isLoading, run } = useFetch("/api/example", { headers }, options)
270+
const { data, error, isPending, run } = useFetch("/api/example", { headers }, options)
271271
// This will setup a promiseFn with a fetch request and JSON deserialization.
272272

273273
// you can later call `run` with an optional callback argument to
@@ -315,8 +315,8 @@ const loadCustomer = ({ customerId }, { signal }) =>
315315

316316
const MyComponent = () => (
317317
<Async promiseFn={loadCustomer} customerId={1}>
318-
{({ data, error, isLoading }) => {
319-
if (isLoading) return "Loading..."
318+
{({ data, error, isPending }) => {
319+
if (isPending) return "Loading..."
320320
if (error) return `Something went wrong: ${error.message}`
321321
if (data)
322322
return (
@@ -404,7 +404,7 @@ const loadCustomer = ({ customerId }, { signal }) =>
404404

405405
const MyComponent = () => (
406406
<Async promiseFn={loadCustomer} customerId={1}>
407-
<Async.Loading>Loading...</Async.Loading>
407+
<Async.Pending>Loading...</Async.Pending>
408408
<Async.Fulfilled>
409409
{data => (
410410
<div>
@@ -895,8 +895,8 @@ class App extends Component {
895895
// The promiseFn should be defined outside of render()
896896
return (
897897
<Async promiseFn={this.getSession} sessionId={123}>
898-
{({ data, error, isLoading, reload }) => {
899-
if (isLoading) {
898+
{({ data, error, isPending, reload }) => {
899+
if (isPending) {
900900
return <div>Loading...</div>
901901
}
902902
if (error) {
@@ -926,10 +926,10 @@ This uses `deferFn` to trigger an update (e.g. POST / PUT request) after a form
926926
const subscribeToNewsletter = (args, props, controller) => fetch(...)
927927

928928
<Async deferFn={subscribeToNewsletter}>
929-
{({ error, isLoading, run }) => (
929+
{({ error, isPending, run }) => (
930930
<form onSubmit={run}>
931931
<input type="email" name="email" />
932-
<button type="submit" disabled={isLoading}>
932+
<button type="submit" disabled={isPending}>
933933
Subscribe
934934
</button>
935935
{error && <p>{error.toString()}</p>}
@@ -946,14 +946,14 @@ This uses both `promiseFn` and `deferFn` along with `setData` to implement optim
946946
const updateAttendance = ([attend]) => fetch(...).then(() => attend, () => !attend)
947947

948948
<Async promiseFn={getAttendance} deferFn={updateAttendance}>
949-
{({ data: isAttending, isLoading, run, setData }) => (
949+
{({ data: isAttending, isPending, run, setData }) => (
950950
<Toggle
951951
on={isAttending}
952952
onClick={() => {
953953
setData(!isAttending)
954954
run(!isAttending)
955955
}}
956-
disabled={isLoading}
956+
disabled={isPending}
957957
/>
958958
)}
959959
</Async>
@@ -974,8 +974,8 @@ render() {
974974
const { customers } = this.props // injected by getInitialProps
975975
return (
976976
<Async promiseFn={loadCustomers} initialValue={customers}>
977-
{({ data, error, isLoading, initialValue }) => { // initialValue is passed along for convenience
978-
if (isLoading) {
977+
{({ data, error, isPending, initialValue }) => { // initialValue is passed along for convenience
978+
if (isPending) {
979979
return <div>Loading...</div>
980980
}
981981
if (error) {

0 commit comments

Comments
 (0)