Moved the evaluation in start of the render option execution.

This commit is contained in:
Owaise Imdad
2025-03-15 22:31:15 +05:30
parent 5825151b28
commit e0e2cec386

View File

@@ -154,6 +154,7 @@ const Search = ({
}}
renderOption={(props, option) => {
const { key, ...optionProps } = props;
const hasSecondaryLabel = secondaryLabel && option[secondaryLabel] !== undefined;
return (
<ListItem
key={key}
@@ -168,9 +169,7 @@ const Search = ({
}
>
{option[filteredBy] +
(secondaryLabel && option[secondaryLabel]
? ` (${option[secondaryLabel]})`
: "")}
(hasSecondaryLabel ? ` (${option[secondaryLabel]})` : "")}
</ListItem>
);
}}