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 }}
This repository was archived by the owner on Mar 26, 2026. It is now read-only.
() =>count() >0?h("span", null, "Positive"):h("span", null, "Zero or negative")
304
-
)
302
+
<div>
303
+
{() =>count() >0?<span>Positive</span>:<span>Zero or negative</span>}
304
+
</div>
305
305
```
306
306
307
307
### Components
308
308
309
-
```ts
309
+
```tsx
310
310
// Render a component
311
-
h(Counter, { initial: 0 })
311
+
<Counterinitial={0} />
312
312
313
313
// Component with children
314
-
h(Card, { title: "Hello" },
315
-
h("p", null, "Card body")
316
-
)
314
+
<Cardtitle="Hello">
315
+
<p>Card body</p>
316
+
</Card>
317
317
```
318
318
319
319
### Fragments
320
320
321
321
Fragments let you group children without adding a wrapper DOM element:
322
322
323
-
```ts
323
+
```tsx
324
324
// Fragment (no wrapper element)
325
-
h(Fragment, null,
326
-
h("span", null, "A"),
327
-
h("span", null, "B")
328
-
)
329
-
330
-
// Equivalent JSX
331
325
<>
332
326
<span>A</span>
333
327
<span>B</span>
@@ -362,12 +356,12 @@ Children can be:
362
356
363
357
`EMPTY_PROPS` is a shared empty object used when `h()` is called with `null` props. The renderer identity-checks against it to skip unnecessary prop application:
@@ -1275,6 +1268,75 @@ Inner boundaries catch errors first. If an inner boundary is already in an error
1275
1268
1276
1269
`ErrorBoundary` uses a module-level stack of handler functions. During setup, it pushes a handler onto the stack. When a child component throws during mount, `dispatchToErrorBoundary()` invokes the innermost handler. The handler stores the error in a signal; when the signal becomes non-null, the fallback renders instead of the children.
1277
1270
1271
+
## Dynamic
1272
+
1273
+
Renders a component or HTML element dynamically based on a reactive value. Useful for rendering polymorphic components or switching between element types at runtime.
/** Component function or HTML tag name to render */
1302
+
component: ComponentFn|string
1303
+
}
1304
+
```
1305
+
1306
+
All other props are forwarded to the resolved component or element. If `component` is falsy, `Dynamic` returns `null`.
1307
+
1308
+
## lazy
1309
+
1310
+
Lazily load a component module. Returns a wrapper component that shows `null` while loading and the resolved component once ready. Pairs with `Suspense` to show a fallback during loading.
1. `lazy()` starts the dynamic `import()` immediately.
1329
+
2. While loading, the wrapper component returns `null` and exposes a `__loading()` signal that returns `true`.
1330
+
3. `Suspense` detects `__loading()` and renders the fallback instead.
1331
+
4. Once the module resolves, the signal flips and `Suspense` renders the actual component.
1332
+
5. If the import fails, the error is thrown during rendering and can be caught by `ErrorBoundary`.
1333
+
1334
+
```ts
1335
+
function lazy<PextendsProps>(
1336
+
load: () => Promise<{default: ComponentFn<P>}>,
1337
+
): LazyComponent<P>
1338
+
```
1339
+
1278
1340
## mapArray
1279
1341
1280
1342
Keyed reactive list mapping that creates each mapped item exactly once per key and reuses it across updates. When the source array is reordered or partially changed, only new keys invoke `map()`; existing entries return the cached result. Removed keys are evicted from the cache.
@@ -1665,6 +1727,8 @@ Dispatch an error to the nearest active `ErrorBoundary`. Returns `true` if the b
0 commit comments