admin管理员组

文章数量:1399482

I can't figure out what prop to use to disable a Creatable React-select ponent, 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.

I can't figure out what prop to use to disable a Creatable React-select ponent, 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.

Share Improve this question edited Feb 1, 2019 at 4:37 Shubham Khatri 282k58 gold badges431 silver badges411 bronze badges asked Feb 1, 2019 at 4:02 joshmkjoshmk 4258 silver badges24 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

The isDisabled prop for Select ponents 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 ponent

render() {
    return (
      <CreatableSelect
        isClearable
        isDisabled
        onChange={this.handleChange}
        onInputChange={this.handleInputChange}
        options={colourOptions}
      />
    );
  }

Working demo with v2

本文标签: javascriptHow do I disable a Creatable reactselect componentStack Overflow