Skip to content

Commit d2bcb48

Browse files
committed
docs: fix key prop in select objects demo
1 parent 88cc7a3 commit d2bcb48

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/site/src/routes/demo/select/_Objects.svelte

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
Note: you need to provide a function as `key` that returns a unique string
55
for each option.
66
7-
It *must* be a string. (Hence the `${fruit.id}` part.)
7+
It *must* be a string. (Hence the `${fruit && fruit.id}` part. That
8+
returns a string for the numberic `id` field and the `null` value even.)
89
-->
9-
<Select key={(fruit) => `${fruit.id}`} bind:value={valueA} label="Standard">
10+
<Select
11+
key={(fruit) => `${fruit && fruit.id}`}
12+
bind:value={valueA}
13+
label="Standard"
14+
>
1015
<Option value={null} />
1116
{#each fruits as fruit (fruit.label)}
1217
<Option value={fruit}>{fruit.label}</Option>
@@ -21,7 +26,7 @@
2126
<div>
2227
<Select
2328
variant="filled"
24-
key={(fruit) => `${fruit.id}`}
29+
key={(fruit) => `${fruit && fruit.id}`}
2530
bind:value={valueB}
2631
label="Filled"
2732
>
@@ -39,7 +44,7 @@
3944
<div>
4045
<Select
4146
variant="outlined"
42-
key={(fruit) => `${fruit.id}`}
47+
key={(fruit) => `${fruit && fruit.id}`}
4348
bind:value={valueC}
4449
label="Outlined"
4550
>

0 commit comments

Comments
 (0)