Ensure the style changes for each dropdown item upon selection
Check out the code snippet provided below
const [selected, setSelected] = useState(null)
const originalOptions = [
{
index: 1,
text: "Davey Jones",
value: "userone",
style: { backgroundColor: 'red'}
},
{
index: 2,
text: "Gengar",
value: "usertwo",
style: selected ? { backgroundColor: 'red'} : null
},
{
index: 3,
text: "Frank Booth",
value: "fbooth",
style: { backgroundColor: 'red'}
}
];
const displayOptions = originalOptions.map(option => {
return
{
...option,
style: selected === option.index ? { backgroundColor: 'red'} : null
}
})
Implement this in your Dropdown component as shown below
<Dropdown
placeholder='Name'
selection
search
className='filter-dropdown'
options={displayOptions}
onChange={(value)=>setSelected(value.index)}
...
/>