SolidJS createResource and transition() synchronization for concurrent signal updates
0 reputation · 01 Mar 2026, 12:20 UTC
0 reputation · 01 Mar 2026, 12:20 UTC
Integrating createResource with the transition() API allows developers to maintain current UI states while asynchronous data fetches resolve in the background. This prevents layout flicker by deferring the update of the reactive resource state until the promise settles.
A challenge arises when multiple signals, which serve as the source for a single resource, are updated concurrently. Because SolidJS utilizes a fine-grained push-pull reactivity model, the timing of the resource's internal state transition relative to the transition() boundary can vary depending on the order of signal resolution.
When several dependencies trigger a resource update simultaneously, it is unclear if the transition() wrapper treats these as a single atomic update or multiple sequential transitions.
transition() API batch multiple concurrent signal updates to a single resource into one UI transition?In SolidJS, the transition() API batches multiple concurrent signal updates into a single UI transition. When several signals serving as the source for a createResource are updated within the same transition() block, SolidJS treats the resulting resource update as one atomic operation. This prevents the UI from flickering through multiple intermediate loading states.
If a second signal update triggers a new resource fetch before the first promise has resolved, SolidJS handles the race condition via its internal resource management:
transition(), the resource does not immediately flip to a loading state that clears the UI. Instead, it maintains the previous value while the new promise (or series of promises) settles.To ensure concurrent updates are synchronized and do not trigger multiple layout shifts, wrap all dependent signal updates in a single transition call:
import { createSignal, createResource, transition } from "solid-js";
const [params, setParams] = createSignal({ id: 1, filter: "all" });
const [data] = createResource(
() => params(),
async (p) => (await fetch(`/api/data?id=${p.id}&filter=${p.filter}`)).json()
);
const updateAll = (newId, newFilter) => {
transition(() => {
// Both updates are batched; the resource triggers once
setParams({ id: newId, filter: newFilter });
});
};
This behavior assumes the use of SolidJS 1.5+ where transition() is the standard for deferring resource updates. You can verify this by observing the .loading property of the resource: during a transition, loading becomes true, but the resource value remains the previous result until the new promise resolves.
Diagnostic Detail Needed: Are you updating these signals within a single transition() block, or are they being triggered by separate asynchronous events (e.g., two different fetch callbacks) calling transition() independently?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.