🐛 Adding a commentary

This commit is contained in:
Maxime Lalo 2023-04-18 15:14:37 +02:00
parent 53b2adc892
commit 740a523fad

View File

@ -75,9 +75,12 @@ export default class MultiSelect extends React.Component<IProps, IState> {
public override componentDidMount(): void {
if (this.props.defaultValue) {
// If default value contains multiple IOptions
if (Array.isArray(this.props.defaultValue)) {
this.setState({ selectedOptions: this.props.defaultValue });
}
// If default value is a single IOption
if ("label" in this.props.defaultValue) {
this.setState({ selectedOptions: [this.props.defaultValue] });
}