Skip to content
Cema edited this page Mar 28, 2016 · 2 revisions

Welcome to the react-select wiki!

For webpack

In order to add CSS styles for React Select use:

require('react-select/less/default.less')

or

require('react-select/dist/default.css')

see https://github.com/JedWatson/react-select/issues/176

Allow Create (temporary solution)

Until allowCreate={true} option doesn't fixed and merged, use one of these solutions:

  1. https://github.com/lefnire/jobpig/commit/ce4bf390f47f41683f1d253c28dc748b14287d67
  2. https://github.com/JedWatson/react-select/pull/660#issuecomment-169249033
  3. filterOptions function:
filterOptions = (options, filter, values) => {
  // Filter already selected values
  let filteredOptions = options.filter(option => {
    return !(values.includes(option));
  });

  // Filter by label
  if (filter !== undefined && filter != null && filter.length > 0) {
    filteredOptions = filteredOptions.filter(option => {
      return RegExp(filter, 'ig').test(option.label);
    });
  }

  // Append Addition option
  if (filteredOptions.length == 0) {
    filteredOptions.push({
      label:  <span><strong>Create</strong>: {filter}</span>,
      value:  filter,
      create: true,
    });
  }

  return filteredOptions;
};

For more information, see: https://github.com/JedWatson/react-select/pull/660

Clone this wiki locally