这是我的代码:
<Select
inputValue={inputValue}
isClearable={false}
isMulti
name="domains"
getOptionLabel={domain => domain.name}
getOptionValue={domain => domain.id}
options={domains}
onChange={this.handleChange}
onInputChange={this.handleInputChange}
onKeyDown={this.handleKeyDown}
value={selectedDomains}
className="basic-multi-select"
classNamePrefix="select"
required
/>
</div>
<FormFeedback>
{errors.selectedDomains && errors.selectedDomains.message}
</FormFeedback>
这是我的功能:
isValidForm = () => {
if (selectedDomains === null) {
errors.selectedDomains = {
message: "Please select domain"
};
}
if (Object.entries(errors).length !== 0) {
return this.setState({ errors }, () => false);
}
return true;
};