2 min lesson
Close cousins on the surface, different mechanics underneath
Use two rows in "Close cousins on the surface, different mechanics underneath" to state the practical decision rules.
Step 1 of 3
Note count() - a signal is a getter you call and that call is what subscribes the surrounding computation. The primitives map roughly onto hooks, but the semantics differ.
- React
useState- Solid
createSignal- What's different
- A getter/setter pair, not a value plus a setter
- React
useEffect- Solid
createEffect- What's different
- No dependency array
- React
useMemo- Solid
createMemo- What's different
- A cached derived signal; downstream readers update only when the memo's value actually changes
- React
- Spreading state objects
- Solid
createStore- What's different
- Nested, fine-grained reactive objects with path-level updates via
setStore
| React | Solid | What's different |
|---|---|---|
useState | createSignal | A getter/setter pair, not a value plus a setter |
useEffect | createEffect | No dependency array |
useMemo | createMemo | A cached derived signal; downstream readers update only when the memo's value actually changes |
| Spreading state objects | createStore | Nested, fine-grained reactive objects with path-level updates via setStore |
Close cousins on the surface, different mechanics underneath.