Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
chore: lazily initialize selected state
Browse files Browse the repository at this point in the history
  • Loading branch information
lwhiteley committed May 26, 2021
1 parent 2cd65fe commit 1b83f08
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const Dropdown: React.FC<ReactDropdownProps> = ({
isClearable,
}) => {
const options = prepareOptions(originalOptions);
const [selected, setSelected] = useState(
const [selected, setSelected] = useState(() =>
findSelected(options, value, matcher),
);
const [isOpen, setIsOpen] = useState(false);
Expand Down
2 changes: 1 addition & 1 deletion src/Selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const Selection: React.FC<SelectionProps> = ({
menu: MenuContainer,
}) => {
const options = prepareOptions(originalOptions);
const [selected, setSelected] = useState(
const [selected, setSelected] = useState(() =>
findSelected(options, value, matcher),
);

Expand Down

0 comments on commit 1b83f08

Please sign in to comment.