Skip to content

Commit 6096558

Browse files
authored
fix: select defaultValue re-render issue (#8816)
fix: select defaultValue changes
1 parent b83294e commit 6096558

File tree

1 file changed

+3
-1
lines changed
  • packages/ui-components/src/Common/Select

1 file changed

+3
-1
lines changed

packages/ui-components/src/Common/Select/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline';
44
import * as SelectPrimitive from '@radix-ui/react-select';
55
import classNames from 'classnames';
6-
import { useId, useMemo, useState } from 'react';
6+
import { useEffect, useId, useMemo, useState } from 'react';
77

88
import Skeleton from '#ui/Common/Skeleton';
99

@@ -64,6 +64,8 @@ const Select = <T extends string>({
6464
const id = useId();
6565
const [value, setValue] = useState(defaultValue);
6666

67+
useEffect(() => setValue(defaultValue), [defaultValue]);
68+
6769
const mappedValues = useMemo(() => mapValues(values), [values]) as Array<
6870
SelectGroup<T>
6971
>;

0 commit comments

Comments
 (0)