I have two <CreatableSelect /> for min and max properties, Is there a way I can disable some options for second <CreatableSelect /> if first <CreatableSelect /> value is less than second <CreatableSelect /> option? I'm using react-select v2. I know isOptionDisabled prop is available but I need to disable options once one of the two has changed. I can also modify the options object that being passed to <CreatableSelect /> and set another property isDisabled but this seems not efficient.
import React from 'react';
import { FormSection, Field } from 'redux-form';
import CreatableSelect from 'react-select/lib/Creatable';
// components
import { LAND_SIZE_OPTIONS } from '../../../../../../constants/search';
const handleInputChange = (newValue, callBack) => {
callBack(false);
};
const handleSelectChange = (newValue, input, callBack) => {
callBack(true);
input.onChange(newValue.value);
};
const RenderSelect = props => (
<CreatableSelect
simpleValue
onChange={newValue => handleSelectChange(newValue, props.input, props.callBack)}
onInputChange={newValue => handleInputChange(newValue, props.callBack)}
options={LAND_SIZE_OPTIONS}
placeholder={props.placeholder}
/>
);
const LandSizeSelect = props => (
<div className="land-size-min-max-container">
<p>Land Size</p>
<div className="menu-select">
<FormSection name="landArea">
<Field
name="min"
component={RenderSelect}
{...{
callBack:
props.overrideDropdownSelectClickOutside,
placeholder: 'Min',
stateValue: props.max,
}}
/>
<Field
name="max"
component={RenderSelect}
{...{
callBack:
props.overrideDropdownSelectClickOutside,
placeholder: 'Max',
stateValue: props.min,
}}
/>
</FormSection>
</div>
</div>
);
export default LandSizeSelect;