In short
See also the mental model for what a component body does once, and Configuration for autoReactive.
- Write plain constants in components; they are live when they read signals or props and are used in JSX or a closure.
- Use
useMemooutside components (hooks, modules), for values you want to name, and whenever the constant is not at the top level of the component body. - Use
<Show>,<Switch>or one returned conditional for branching; never an earlyreturnthat depends on a signal. - Do not reuse a derived constant's name in an inner scope.
See also the mental model for what a component body does once, and
Configuration for autoReactive.