hc-oss / react-multi-select-component

Lightweight (~5KB gzipped) multiple selection dropdown component

Home Page:https://codesandbox.io/s/react-multi-select-example-uqtgs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can we get array from mulselect component?

ghulamyazdani opened this issue · comments

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Right now we are getting the whole object when we select an option, just wanted to ask if we can get array of selected options. if not can we add this feature?

current version has this -
image -
want this
image

@ghulamyazdani

you should be able to easily do it like below

const selectedValues = useMemo(() => {
  return selected.map((s) => s.value);
}, [selected]);

or otherwise if you want simple component here's sandbox sample

https://codesandbox.io/s/nostalgic-bush-pvv4zz

as of now there are no plans/bandwith for me to support this is just extra maintainablity plus increases bundle size similar results can be easily achieved using little bit of code