UNPKG

react-bootstrap-typeahead

Version:
14 lines (13 loc) 426 B
import getOptionLabel from './getOptionLabel'; import { isFunction } from './nodash'; function addCustomOption(results, props) { const { allowNew, labelKey, text } = props; if (!allowNew || !text.trim()) { return false; } if (isFunction(allowNew)) { return allowNew(results, props); } return !results.some((o) => getOptionLabel(o, labelKey) === text); } export default addCustomOption;