I've got a FluentUI Dropdown component in a Sharepoint webpart that's acting strangely, it's defined as follows:
<Dropdown
defaultSelectedKey={new Date().getMonth()}
options={getMonthSelection()}
styles={dropdownStyles}
onChange={this.handleTimePeriodChange}
selectedKey={this.state.month}
/>
When the onChange event fires it calls the following function:
private handleTimePeriodChange(event, option, index) {
this.setState({
month: option.key
});
}
Everything works totally fine except that the Dropdown UI element doesn't change to reflect the new selection. If I remove the call to setState() then the UI element updates to reflect the selection but then the state isn't updated.
Can anyone see where I'm going wrong and if there's a way I can update the state properties without breaking the UI element?