I'm using Semantic UI React to create a select country dropdown. In order to get values that are passed as attributes to a <div role=option />
.
In order to get the selected div I use this:
handleSelectCountry = (e, props) => {
const selected = $('div.item[aria-selected=true]');
const flag = selected.get(0).children[0].className;
console.log(selected);
this.setState({ country: props.value, flag });
};
When logged, it logs the previous selected div as <div role="option" aria-selected="false">Previous selected</div>
However, using the same selector in the Chrome console gives the correct <div role=option aria-selected="true">Current selected</div>
.
The DropDown code is (from semantic-ui-react):
<Dropdown
fluid
required
placeholder="Select Country"
search
selection
options={Form.countryList}
value={country}
onChange={this.handleSelectCountry}
/>