I am a React noob, and also new to react-select (v2).
I think our scenario is fairly simple. We are pulling data from Azure Search (facets), and want to bind to a slightly customized react-select control.
We want to:
- Add in a badge/pill to display counts in the dropdown.
- Avoid looping through returned data to dupe value and label in react-select options.
We have gotten most of the way there, with help from this example (which was more helpful than the official docs IMO) : React-Select - Replacing Components for custom option content. The only thing missing is applying the default react-select styles (eg: for hover).
Data Example:
const myOptions = [
{ value: 'foo', count: 100 },
{ value: 'bar', count: 200 },
];
Custom Control Example:
const CustomOption = (props:any) => {
const { innerProps, innerRef } = props;
return (
<article ref={innerRef} {...innerProps} >
<div style={{display:"inline-block"}}>{props.data.value}</div>
<span className="badge badge-light float-right" style={{display:"inline-block"}}>{props.data.count} </span>
</article>
);
};
Is there a way to reuse the default react-select styles? Am I missing something in the docs?