Skip to content

Commit 8d5a5ae

Browse files
committed
update
1 parent 878aa46 commit 8d5a5ae

7 files changed

Lines changed: 37 additions & 25 deletions

File tree

src/routes/reference/components/create-dynamic.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,25 @@ Returns the rendered component or element.
6262
## Example
6363

6464
```tsx
65+
import { createSignal } from "solid-js";
66+
6567
const views = {
66-
red: () => <p style={{ color: "red" }}>Red</p>,
67-
blue: () => <p style={{ color: "blue" }}>Blue</p>,
68+
red: (props: { label: string }) => <p style={{ color: "red" }}>{props.label}</p>,
69+
blue: (props: { label: string }) => <p style={{ color: "blue" }}>{props.label}</p>,
6870
};
6971

70-
const [selected, setSelected] = createSignal<keyof typeof views>("red");
72+
function App() {
73+
const [selected, setSelected] = createSignal<keyof typeof views>("red");
7174

7275
return (
7376
<>
7477
<button onClick={() => setSelected("red")}>Red</button>
7578
<button onClick={() => setSelected("blue")}>Blue</button>
7679

77-
{createDynamic(() => views[selected()], {})}
80+
{createDynamic(() => views[selected()], { label: "Selected view" })}
7881
</>
7982
);
83+
}
8084
```
8185

8286
## Related

src/routes/reference/components/dynamic.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,25 @@ Returns the rendered component or element.
6666
## Example
6767

6868
```tsx
69+
import { createSignal } from "solid-js";
70+
6971
const views = {
70-
red: () => <p style={{ color: "red" }}>Red</p>,
71-
blue: () => <p style={{ color: "blue" }}>Blue</p>,
72+
red: (props: { label: string }) => <p style={{ color: "red" }}>{props.label}</p>,
73+
blue: (props: { label: string }) => <p style={{ color: "blue" }}>{props.label}</p>,
7274
};
7375

74-
const [selected, setSelected] = createSignal<keyof typeof views>("red");
76+
function App() {
77+
const [selected, setSelected] = createSignal<keyof typeof views>("red");
7578

7679
return (
7780
<>
7881
<button onClick={() => setSelected("red")}>Red</button>
7982
<button onClick={() => setSelected("blue")}>Blue</button>
8083

81-
<Dynamic component={views[selected()]} />
84+
<Dynamic component={views[selected()]} label="Selected view" />
8285
</>
8386
);
87+
}
8488
```
8589

8690
## Related

src/routes/reference/components/error-boundary.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,14 @@ Returns the rendered children or fallback content.
6464
### Basic usage
6565

6666
```tsx
67+
function ErrorProne() {
68+
throw new Error("Broken");
69+
}
70+
6771
<ErrorBoundary
6872
fallback={(error, reset) => (
6973
<div>
70-
<p>{error.message}</p>
74+
<p>{String(error)}</p>
7175
<button onClick={reset}>Try Again</button>
7276
</div>
7377
)}

src/routes/reference/components/for.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const items = ["A", "B", "C"];
8888
<For each={items}>
8989
{(item, index) => (
9090
<div>
91-
#{index} {item}
91+
#{index()} {item}
9292
</div>
9393
)}
9494
</For>;

src/routes/reference/components/no-hydration.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ Returns the server-rendered children.
5656
function Example() {
5757
return (
5858
<div>
59-
<InteractiveComponent />
59+
<button>Interactive button</button>
6060
<NoHydration>
61-
<StaticContent />
61+
<div innerHTML={"<strong>Server-rendered only</strong>"} />
6262
</NoHydration>
6363
</div>
6464
);

src/routes/reference/components/portal.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,11 @@ Returns a marker node used to preserve the portal position in the component tree
8989

9090
```tsx
9191
import { createSignal, Show } from "solid-js";
92-
import { Portal } from "solid-js/web";
9392

9493
function App() {
95-
const [open, setOpen] = createSignal(false);
94+
const [open, setOpen] = createSignal(false);
9695

97-
return (
96+
return (
9897
<>
9998
<button onClick={() => setOpen(true)}>Open</button>
10099

src/routes/reference/components/show.mdx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,45 +67,46 @@ Content rendered when `when` is falsy.
6767

6868
### `children`
6969

70-
- **Type:** `JSX.Element | ((item) => JSX.Element)`
70+
- **Type:** `JSX.Element | ((item: Accessor<NonNullable<T>>) => JSX.Element) | ((item: NonNullable<T>) => JSX.Element)`
7171

72-
Content rendered when `when` is truthy. Function children receive an accessor or value based on `keyed`.
72+
Content rendered when `when` is truthy.
7373

7474
## Return value
7575

7676
- **Type:** `JSX.Element`
7777

78+
Returns the rendered children or `fallback` content.
79+
7880
## Behavior
7981

80-
- With `keyed` omitted or `false`, `<Show>` re-renders only when the truthiness of `when` changes.
81-
- With `keyed={true}`, changes to the `when` value itself trigger a new render even when the value remains truthy.
82+
- With `keyed` omitted or `false`, `<Show>` updates only when the truthiness of `when` changes. Replacing one truthy value with another truthy value does not recreate the child block, and function children receive an accessor that can only be read while the condition remains truthy.
83+
- With `keyed={true}`, changes to the `when` value trigger a new render even when the value remains truthy, and function children receive the value directly.
8284
- Function children are wrapped in [`untrack`](/reference/reactive-utilities/untrack).
83-
- With `keyed={false}`, function children receive an accessor for the current non-nullish value; with `keyed={true}`, they receive the value directly.
8485

8586
## Examples
8687

8788
### Basic usage
8889

8990
```tsx
90-
import { Show } from "solid-js";
91+
const loading = () => false;
9192

92-
<Show when={value()} fallback={<div>Fallback Element</div>}>
93-
<div>Child Element</div>
93+
<Show when={!loading()} fallback={<div>Loading...</div>}>
94+
<div>Loaded</div>
9495
</Show>;
9596
```
9697

9798
### Function child
9899

99100
```tsx
100-
import { Show } from "solid-js";
101+
const user = () => ({ name: "Ada" });
101102

102103
<Show when={user()}>{(user) => <div>{user().name}</div>}</Show>;
103104
```
104105

105106
### Keyed function child
106107

107108
```tsx
108-
import { Show } from "solid-js";
109+
const user = () => ({ name: "Ada" });
109110

110111
<Show when={user()} keyed>
111112
{(user) => <div>{user.name}</div>}

0 commit comments

Comments
 (0)