1.0.0 • Published 6 years ago

react-editable-select v1.0.0

Weekly downloads
541
License
MIT
Repository
-
Last release
6 years ago

react-editable-select

A select component that can be switched to text input to allow adding new elements.

Prerequesites

  • reactstrap
  • bootstrap
  • font-awesome
  • yarn
  • webpack
  • es6

Try it out

  • Activate nodejs
nvm use
  • Install yarn
npm -g install yarn
  • Start webpack dev server
yarn start

How to use

import {EditableSelect} from 'react-editable-select';

...

<EditableSelect
    options={options}
    value={selectedOption}
    getOptionValue={(option) => option.id}
    getOptionLabel={(option) => option.name}
    createOption={(text) => { return {id: 1, name: text} }}
    onChange={(ev, option) => ...}
    />
PropertyDescription
optionsArray of options
valueCurrently selected option
getOptionValueCallback to convert option into option key
getOptionLabelCallback to convert option into option label
createOptionCallback to create a new option
onChangeCallback invoked when option is selected or text field changes

License

MIT