Under The Hood
frontend solidjs SolidJS 1.x / 2.x

Zero Virtual DOM: Components Run Once as Setup Functions

Last updated
Prerequisites:
React rendering model vs SolidJS reactivity
SolidJS createSignal
  • solidjs
  • reactivity
  • lifecycle
  • signals
  • compiler
  • architecture

Read at your depth

The practical view

In SolidJS, **component functions execute exactly once** when they are created (mounted). They never re-render. When a signal updates via `setCount()`, the component function does *not* re-run. Instead, only the specific micro-expression or DOM node that called `count()` updates directly. Destructuring props in the function signature (`function App({ count })`) breaks reactivity because the function never re-runs to receive new prop values.

The same idea in other frameworks

react equivalent
Component function re-runs on every state change; requires `useMemo`/`useCallback`.

Legacy vs modern

React Component Re-Render vs SolidJS Run-Once Execution

Console logs in React run on every click; in SolidJS, the component body runs once and only the DOM binding updates.

before → after
React Re-Rendering Component
const [count, setCount] = useState(0); console.log('Rendered'); // ❌ Logs on every click
SolidJS Run-Once Component
const [count, setCount] = createSignal(0); console.log('Mounted'); // ✅ Runs ONLY ONCE

Interview gotchas

Context

This is the #1 gotcha interviewers use to check if a developer understands Solid's execution model.

The mechanical answer

Because Solid components run **only once**, destructuring `props` in the function parameter (e.g. `function Card({ title })`) extracts the property's raw primitive value at the exact moment of initial setup. When the parent component passes a new `title`, the child component function does not re-run, so `title` remains frozen as its initial value. To preserve reactivity, you must access props via property access `props.title` or use `splitProps(props, [...])`.

Trap

Never write `const { name, age } = props;` in SolidJS. Always use `props.name` or helper utilities like `mergeProps` / `splitProps`.

Under The Hood — a multi-depth technical interview hub.

Third-party licenses Press ⌘ K to search.