You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
I'm unable to understand what createDeffered and createMemo differ just from the description
#4783
Maybe because I'm trying to understand it just after I woke up, but I cannot come to a conclusion on when it is recommend to use one instead of the other.
The core difference comes down to synchronous caching vs scheduling / deferred priority.
createMemo
createMemo computes a derived value synchronously. Whenever any dependency signal inside the memo changes, Solid re-runs the computation immediately during the current reactive update and caches the result. Subsequent reads return the cached value until a dependency updates again.
Behavior: Runs immediately, always up-to-date with dependencies.
When to use: Pure derived state or expensive computations that your UI or other effects need right now.
createDeferred wraps an existing signal/accessor and returns a new accessor whose updates are deferred until the main thread is idle (using concurrent transitions under the hood). If the upstream signal changes rapidly (e.g. typing in an input field), the deferred signal holds onto its previous, stale value until high-priority work finishes.
Behavior: Yields to user interactions; keeps the UI responsive by postponing expensive downstream updates.
When to use: When you have an expensive UI subtree (such as filtering an enormous data table or rendering hundreds of DOM elements) triggered by rapid user input.
const[query,setQuery]=createSignal('');// deferredQuery lags behind query during rapid typing so the input doesn't stutterconstdeferredQuery=createDeferred(()=>query());return(<><inputvalue={query()}onInput={(e)=>setQuery(e.target.value)}/><HeavyListfilter={deferredQuery()}/></>);
In short: use createMemo when you want to compute derived state without recalculating on every read. Use createDeferred when you want to deliberately let non-critical UI lag behind high-priority interactions to avoid dropped frames.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Maybe because I'm trying to understand it just after I woke up, but I cannot come to a conclusion on when it is recommend to use one instead of the other.
All reactions