Combobox: Accepting object as well as value in ComboboxItem #3508
-
Thanks for the awesome library. Currently, I am doing |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Instead of const options = [
{ value: "a", label: "A" },
{ value: "b", label: "B" },
{ value: "c", label: "C" },
];
function getOptionFromValue(value: string) {
return options.find((option) => option.value === value);
}
<ComboboxProvider
setSelectedValue={(value) => {
const option = getOptionFromValue(value);
...
}} |
Beta Was this translation helpful? Give feedback.
Instead of
JSON.stringify
, you can maintain a separate array with your objects (which you probably already have) and retrieve the object for the value onsetSelectedValue
: