2

I'm using React-semantic-ui dropdown. I can't seem to find how to add a data-attribute to the dropdown options. I'd like to add data-key attribute to the drop-down options and then use those keys later.

I found this resource here but this doesn't help.

<div className="dropdownMenu">
    <Dropdown
        fluid
        search
        selection
        options={countries}
        placeholder="Select Country"
        onChange={updateCountry}
        defaultValue={selectedCountry}
    />
</div>
Yevhen Horbunkov
  • 14,965
  • 3
  • 20
  • 42
abidishajia
  • 222
  • 1
  • 6
  • 15
  • You may share some live sample of your project (e.g. at [codesandbox](https://codesandbox.io) or [stackblitz](https://stackblitz.com) ) to better understand your use case – Yevhen Horbunkov May 28 '20 at 18:19
  • what you mean by data-attribute? can you explain? – Shivaraj May 29 '20 at 03:04
  • @Shivaraj I believe OP means like a `data-something` in the dataset of each of the option tags. To put it on the dropdown itself, you could just include `foo={"bar"}` and get it back with `data-foo`, but how do you pass something through to each of the options? OP, if that's correct, please include it in your question! – thumbtackthief Jun 17 '20 at 02:38

0 Answers0