I have a drop down:
<Dropdown
id="JobPlanDD"
selectedKey={(this.state["JobPlanDD-option"]) ? (this.state["JobPlanDD-option"]).key : undefined}
placeholder="Select..."
onChange={(e, i) => this.handleChange(e, i)}
options={jobPlanDDOptions}
/>
And I have a handler for that drop down and any others I make in the future:
const id = evt.target.querySelector('span').id;
const theItem = item.text;
this.setState({
[id]: theItem
});
For this particular drop down I've been told to use JobPlanDD-option
in the selectedKey
property but I don't understand why.
I manage to log the id of the of the particular drop down thanks to the handler
const id = evt.target.querySelector('span').id;
but it returns JobPlanDD-option
which can't be a state because it has a hyphen or minus.
Can someone explain to me what's going on here?
I have read this and although it describes much, it doesn't completely pertain to my question: Reactjs setState() with a dynamic key name?