How do I disable a Creatable react-select component?

痞子三分冷 提交于 2021-01-27 12:11:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!