Components and control flow
Components and control flow in the Migrating from Solid and SolidStart guide.
| Solid | ShadowJS | What differs |
|---|---|---|
<Show when keyed fallback> |
Show |
Same. Without keyed, a callback child receives an accessor; with keyed it receives the value. |
<Switch fallback>, <Match when> |
Switch, Match |
Same. A child of Switch that is not a Match throws a TypeError. |
<For each fallback> |
For |
Same for unkeyed rows: (item, index) => where item is the plain value and index is an accessor. For over a store array updates on push, splice and index writes. |
<For each key={fn}> |
For with key |
ShadowJS only. The callback then receives item() as an accessor, and a new object under the same key updates the row in place. |
<Index each> |
Index |
Same: (item, index) => with item an accessor and index a number. |
<Dynamic component>, createDynamic(component, props) |
Dynamic, createDynamic(() => component, props) |
Same. createDynamic takes an accessor of the target. Tag names are validated and script is refused. Works in server rendering. |
<Portal mount> |
Portal |
mount defaults to document.body. The content is inserted directly: no wrapper div, no ref. Events follow the DOM tree, not the component tree: a handler on a component ancestor does not see events from inside a portal. useShadow attaches a shadow root. |
<ErrorBoundary fallback> |
ErrorBoundary |
Same: fallback(error, reset). |
<Suspense fallback> |
Suspense |
Same: the boundary around where a resource is read shows its fallback, and onMount and effects of its subtree wait until it resolves. |
lazy(() => import("./x")) |
lazy(...) |
Same. Component.preload() resolves to the component function, not the module object. |
<ClientOnly fallback> (SolidStart clientOnly) |
ClientOnly |
Renders fallback on the server and in the first client pass; the children replace it once the component has mounted. Compose with lazy for a lazy client-only component. |
<SuspenseList revealOrder tail> |
SuspenseList |
Coordinates the Suspense boundaries below it so independent loads reveal in a set order. |
<NoHydration> |
NoHydration |
The server renders the children without hydration keys; the browser leaves that markup untouched while the page hydrates. A client-side navigation renders them normally. |
@solidjs/meta <Title>, <Meta>, <Link>, <Style>, <Base>, useHead |
same names from @shadow-js/web |
No <MetaProvider>: a per-document registry makes the wrapper unnecessary (remove it). Tags carry data-shadow-head. On the server they go to a createServerHead() collector passed as the head option, not into the returned markup; see Server rendering. |