@@ -267,7 +267,7 @@ by passing in the state, or with `<Async>` by using Context. Each of these compo
267267rendering of its children based on the current state.
268268
269269``` jsx
270- import { useAsync , Pending , Fulfilled , Rejected } from " react-async"
270+ import { useAsync , IfPending , IfFulfilled , IfRejected } from " react-async"
271271
272272const loadCustomer = async ({ customerId }, { signal }) => {
273273 // ...
@@ -277,16 +277,16 @@ const MyComponent = () => {
277277 const state = useAsync ({ promiseFn: loadCustomer, customerId: 1 })
278278 return (
279279 <>
280- < Pending state= {state}> Loading... < / Pending >
281- < Rejected state= {state}> {error => ` Something went wrong: ${ error .message } ` }< / Rejected >
282- < Fulfilled state= {state}>
280+ < IfPending state= {state}> Loading... < / IfPending >
281+ < IfRejected state= {state}> {error => ` Something went wrong: ${ error .message } ` }< / IfRejected >
282+ < IfFulfilled state= {state}>
283283 {data => (
284284 < div>
285285 < strong> Loaded some data: < / strong>
286286 < pre> {JSON .stringify (data, null , 2 )}< / pre>
287287 < / div>
288288 )}
289- < / Fulfilled >
289+ < / IfFulfilled >
290290 < / >
291291 )
292292}
@@ -607,7 +607,7 @@ invoked after the state update is completed. Returns the error to enable chainin
607607React Async provides several helper components that make your JSX more declarative and less cluttered.
608608They don't have to be direct children of ` <Async> ` and you can use the same component several times.
609609
610- ### ` <Initial > ` / ` <Async.Initial> `
610+ ### ` <IfInitial > ` / ` <Async.Initial> `
611611
612612Renders only while the deferred promise is still waiting to be run, or you have not provided any promise.
613613
@@ -622,9 +622,9 @@ Renders only while the deferred promise is still waiting to be run, or you have
622622``` jsx
623623const state = useAsync (... )
624624return (
625- < Initial state= {state}>
625+ < IfInitial state= {state}>
626626 < p> This text is only rendered while ` run` has not yet been invoked on ` deferFn` .< / p>
627- < / Initial >
627+ < / IfInitial >
628628)
629629```
630630
@@ -650,7 +650,7 @@ return (
650650< / Async .Initial >
651651```
652652
653- ### ` <Pending > ` / ` <Async.Pending> `
653+ ### ` <IfPending > ` / ` <Async.Pending> `
654654
655655This component renders only while the promise is pending (loading / unsettled).
656656
@@ -667,9 +667,9 @@ Alias: `<Async.Loading>`
667667``` jsx
668668const state = useAsync (... )
669669return (
670- < Pending state= {state}>
670+ < IfPending state= {state}>
671671 < p> This text is only rendered while performing the initial load.< / p>
672- < / Pending >
672+ < / IfPending >
673673)
674674```
675675
@@ -683,7 +683,7 @@ return (
683683< Async .Pending > {({ startedAt }) => ` Loading since ${ startedAt .toISOString ()} ` }< / Async .Pending >
684684```
685685
686- ### ` <Fulfilled > ` / ` <Async.Fulfilled> `
686+ ### ` <IfFulfilled > ` / ` <Async.Fulfilled> `
687687
688688This component renders only when the promise is fulfilled (resolved to a value, could be ` undefined ` ).
689689
@@ -700,9 +700,9 @@ Alias: `<Async.Resolved>`
700700``` jsx
701701const state = useAsync (... )
702702return (
703- < Fulfilled state= {state}>
703+ < IfFulfilled state= {state}>
704704 {data => < pre> {JSON .stringify (data)}< / pre> }
705- < / Fulfilled >
705+ < / IfFulfilled >
706706)
707707```
708708
@@ -716,7 +716,7 @@ return (
716716< / Async .Fulfilled >
717717```
718718
719- ### ` <Rejected > ` / ` <Async.Rejected> `
719+ ### ` <IfRejected > ` / ` <Async.Rejected> `
720720
721721This component renders only when the promise is rejected.
722722
@@ -730,7 +730,7 @@ This component renders only when the promise is rejected.
730730
731731``` jsx
732732const state = useAsync (... )
733- return < Rejected state= {state}> Oops.< / Rejected >
733+ return < IfRejected state= {state}> Oops.< / IfRejected >
734734```
735735
736736``` jsx
@@ -741,7 +741,7 @@ return <Rejected state={state}>Oops.</Rejected>
741741< Async .Rejected > {error => ` Unexpected error: ${ error .message } ` }< / Async .Rejected >
742742```
743743
744- ### ` <Settled > ` / ` <Async.Settled> `
744+ ### ` <IfSettled > ` / ` <Async.Settled> `
745745
746746This component renders only when the promise is fulfilled or rejected.
747747
@@ -755,7 +755,7 @@ This component renders only when the promise is fulfilled or rejected.
755755
756756``` jsx
757757const state = useAsync (... )
758- return < Settled state= {state}> {state => ` Finished at ${ state .finishedAt .toISOString ()} ` < / Settled >
758+ return < IfSettled state= {state}> {state => ` Finished at ${ state .finishedAt .toISOString ()} ` < / IfSettled >
759759` ` `
760760
761761## Usage examples
0 commit comments