I am using react-select and the creatable function that allows you to create a new select option - just type in the select/input field on example.
I want to put a check in that only allows one creatable option to be made at one time, the next created option removes and supersedes the previous. At the moment yo can create an infinite amount.
This is the part that handles the created option so guess I need to add some sort of rule to only allow one option here.
Any help appreciated.
handleCreate = input => (inputValue: any) => {
this.setState({ isLoading: true });
setTimeout(() => {
const { options } = this.state;
const newOption = createOption(inputValue);
this.setState({
isLoading: false,
options: [...options, newOption],
value: newOption
});
input.onChange(newOption);
}, 1000);
};