isPending
Edit this pageimport { isPending } from "solid-js"
function isPending(fn: () => any): booleanisPending answers: "Does this expression currently have pending async work while also having a usable stale value?"
For a conceptual overview of the async model, see Async Reactivity.
Key behavior
- False during initial
Loadingfallback — there is no stale value yet, and the suspended subtree isn't producing UI. - True during revalidation — once you've rendered at least once and the data is being refreshed in the background.
- Reactive —
isPending()can be used directly in JSX or any reactive scope; it tracks dependencies and updates automatically. - Works with actions — reflects pending state from transitions created by
action().
This makes it ideal for showing subtle "refreshing…" indicators without replacing the whole subtree with a spinner.
Usage
import { createMemo, isPending, Show } from "solid-js"
const users = createMemo(() => fetchUsers())
function UserList() { return ( <> <Show when={isPending(() => users())}> <div class="refreshing-banner">Refreshing...</div> </Show> <Loading fallback={<Spinner />}> <List users={users()} /> </Loading> </> )}Combining multiple sources
You can check pending state across multiple async computations by reading them within the same expression:
const users = createMemo(() => fetchUsers())const posts = createMemo(() => fetchPosts())
// Read both values to track pending state for eitherconst listPending = () => isPending(() => { users(); posts() })Replaces .loading
In Solid 1.x, createResource had a .loading property. isPending replaces this with a more general mechanism that works for any expression:
// 1.xdata.loading
// 2.0isPending(() => data())