Skip to content

Commit f167408

Browse files
React to initialValue even if initially undefined on Select.
Move the check for `undefined` into the effect itself. This enables the `initialValue` to be changed from the default (`undefined`) later and still have the `Select` component react to that. Note this is done only for the `Select` component as `undefined` is not a valid value to pass to `setValue` in the core. Supporting it would introduce complexity because a `multiple` value should always be an Array.
1 parent 558545a commit f167408

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/select.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,12 @@ const Select = (props: SelectProps) => {
6363
);
6464
const select = createSelect(selectProps);
6565

66-
if (local.initialValue !== undefined) {
67-
createEffect(
68-
on(
69-
() => local.initialValue,
70-
(value) => select.setValue(value)
71-
)
72-
);
73-
}
66+
createEffect(
67+
on(
68+
() => local.initialValue,
69+
(value) => value !== undefined && select.setValue(value)
70+
)
71+
);
7472

7573
return (
7674
<Container

0 commit comments

Comments
 (0)