问题
I can't figure out what prop to use to disable a Creatable React-select component, is it just missing?
I tried the regular isDisabled prop but was unsuccessful.
<CreatableSelect
name="serviceOrders"
className="hide-options"
value={selectOptions()}
isDisabled={headerLock}
onChange={e => {
this.handleHeaderChange(
e,
'serviceOrders',
);
}}
placeholder="Type SO, then press enter..."
multi
/>
I want to disable it for specific situations.
回答1:
The isDisabled
prop for Select components is applicable for react-select v2 and above. In case you are using a version 1.x.x please use the disabled
prop to disable the select component
render() {
return (
<CreatableSelect
isClearable
isDisabled
onChange={this.handleChange}
onInputChange={this.handleInputChange}
options={colourOptions}
/>
);
}
Working demo with v2
来源:https://stackoverflow.com/questions/54472717/how-do-i-disable-a-creatable-react-select-component