Skip to content

Commit

Permalink
[perf] reduce rerender shenanigans
Browse files Browse the repository at this point in the history
`= []` will cause a new instantiation every rerender, which makes the useMemo useless - just optional chaining instead
  • Loading branch information
cee-chen committed Nov 14, 2023
1 parent a2cb871 commit 91490be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/form/super_select/super_select_control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const EuiSuperSelectControl: <T = string>(
const { defaultFullWidth } = useFormContext();
const {
className,
options = [],
options,
id,
name,
fullWidth = defaultFullWidth,
Expand Down Expand Up @@ -119,7 +119,7 @@ export const EuiSuperSelectControl: <T = string>(

const selectedValue = useMemo(() => {
if (inputValue != null) {
const selectedOption = options.find(
const selectedOption = options?.find(
(option) => option.value === inputValue
);
return selectedOption ? selectedOption.inputDisplay : undefined;
Expand Down

0 comments on commit 91490be

Please sign in to comment.