Was this helpful?
<Async.Initial persist>
{({ error, isPending, run }) => (
<div>
<p>This text is only rendered while the promise has not fulfilled yet.</p>
<button onClick={run} disabled={!isPending}>
Run
</button>
{error && <p>{error.message}</p>}
</div>
)}
</Async.Initial>const state = useAsync(...)
return (
<IfPending state={state}>
<p>This text is only rendered while performing the initial load.</p>
</IfPending>
)<Async.Pending initial>
<p>This text is only rendered while performing the initial load.</p>
</Async.Pending><Async.Pending>{({ startedAt }) => `Loading since ${startedAt.toISOString()}`}</Async.Pending>const state = useAsync(...)
return (
<IfFulfilled state={state}>
{data => <pre>{JSON.stringify(data)}</pre>}
</IfFulfilled>
)<Async.Fulfilled persist>{data => <pre>{JSON.stringify(data)}</pre>}</Async.Fulfilled><Async.Fulfilled>
{(data, { finishedAt }) => `Last updated ${finishedAt.toISOString()}`}
</Async.Fulfilled>