You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 615da44
Browse filesBrowse the repository at this point in the historyBrowse files
This is the least efficient way to use Solid as it requires a slightly larger runtime that isn't treeshakeable, and cannot leverage anything in the way of analysis, so it requires manual wrapping of expressions and has a few other caveats (see below).
19
19
20
-
> `h(...)` returns a tagged zero-arity thunk rather than a DOM node directly;
21
-
> calling it creates the element or component. Pass the thunk itself to
> `render` calls it once inside the root. Do not wrap it as
24
-
> `render(() => h(App), el)` or pass a component that returns an `h(...)`
25
-
> thunk (`render(App, el)`): the uncalled thunk then reaches the renderer as a
26
-
> reactive expression and is created again whenever its output changes — a
27
-
> root `<Show>` is rebuilt on every toggle, and a root `<Loading>` over async
28
-
> children never settles. Nested `h(...)` thunks, including those returned
29
-
> from accessors like `() => (show() ? h(A) : h(B))`, are created once where
30
-
> they are consumed, so composition with control-flow components like `<For>`
31
-
> and `<Show>` works without extra wrapping.
20
+
**Rendering:**`render(h(App), el)`.
21
+
22
+
`h(...)` already returns a thunk: `h(App)` is the equivalent of JSX's `() => <App />`, so pass it straight to `render`. Wrapping it again (`render(() => h(App), el)`) or passing a component that returns an `h(...)` thunk (`render(App, el)`) adds one function too many. The renderer then treats the inner thunk as a reactive expression and re-creates the component whenever its output changes: a root `<Show>` is rebuilt on every toggle, and a root `<Loading>` over async children never settles.
23
+
24
+
Nested `h(...)` thunks, including ones returned from accessors like `() => (show() ? h(A) : h(B))`, are created once where they are consumed, so composition with `<For>`, `<Show>` and other control flow needs no extra wrapping.
0 commit comments