| name | solidjs-reactivity |
| description | Implements SolidJS reactive patterns using signals, effects, and memos. Use when writing or reviewing SolidJS components, state management, or reactive code. Covers the core mental model: components run once, signals track in reactive scopes, and props must not be destructured. |
SolidJS Reactivity
Core Mental Model
SolidJS is NOT React. The fundamental differences:
- Components run once — A component function executes a single time to set up the reactive graph. It never re-runs.
- Reactivity is automatic — Signal reads inside tracking scopes create subscriptions. No dependency arrays.
- Fine-grained updates — Only the specific DOM nodes or computations that depend on a signal update when it changes. No virtual DOM diffing.
function Counter() {
const [count, setCount] = createSignal(0);
console.log("This logs once, not on every update");
return <button onClick={() => setCount(c => c + 1)}>{count()}</button>;
}
createSignal
Creates a reactive value with a getter (accessor) and setter.
{ createSignal } ;
[count, setCount] = ();
();
();
( prev + );