The Promise of Surgical Precision
To understand the trap, you first have to appreciate what makes Solid.js different. Unlike frameworks such as React that re-render entire components to reflect state changes, Solid.js operates with surgical precision. Its components are, in essence, setup
functions that run only once. The magic lies in its “fine-grained reactivity,” where individual pieces of data, called signals, are wired directly to the parts of the DOM that depend on them. When a signal's value changes, only that specific, tiny piece of the user interface updates. There's no virtual DOM, no complex diffing—just a direct, efficient update. This is why it feels so incredibly fast.
The Innocent-Looking Mistake
Here’s where the trouble starts. Developers coming from other frameworks are used to using standard JavaScript expressions directly within their JSX, like mapping over an array or using a ternary operator for conditional rendering. In Solid.js, doing this can unknowingly break the performance model. Consider this common pattern: using `array.map()` to render a list. While it works, it’s not the Solid-native way. The real trap is more subtle: calling a function that performs a calculation directly inside the JSX. For instance, imagine you have a function that filters a list based on a search term signal. If you call that function directly in your view, you might be forcing more work than necessary, creating a new array on every single change, even if it could have been optimized.
Why It Breaks the Reactive Model
The core issue is that Solid’s reactivity is based on tracking when signals are read within a reactive scope (like JSX or an effect). When you use plain JavaScript control flow like `.map()` or a simple function call that computes a value, you can inadvertently sidestep Solid's optimized system. The framework provides specialized components like `
The Solution: Thinking in Primitives
The fix is to embrace Solid's primitives. For derived data—values computed from one or more signals—the tool is `createMemo`. By wrapping your expensive calculation in `createMemo`, you create a new, memoized signal. This new signal will only re-calculate its value when one of its underlying dependencies changes. When the UI reads this memoized value multiple times, it gets the cached result instantly without re-running the calculation. For rendering lists, use the `

















