项目作者: mariostasos

项目描述 :
React Custom Selector Demo
高级语言: JavaScript
项目地址: git://github.com/mariostasos/react-custom-selector.git
创建时间: 2017-03-23T17:13:02Z
项目社区:https://github.com/mariostasos/react-custom-selector

开源协议:MIT License

下载


react-custom-selector

Simple and customizable react select element.

Demo & Examples

Live demo: mariostasos.github.io/react-custom-selector

To build the examples locally, run:

  1. npm install
  2. npm start

Then open localhost:8000 in a browser.

Installation

  1. npm install react-custom-selector --save

Usage

Import the module in to your project

  1. let ReactCustomSelector = require('react-custom-selector');
  2. Or
  3. import ReactCustomSelector from 'react-custom-selector';
  4. and simply use it
  5. <ReactCustomSelector
  6. options={your_array}
  7. placeholder={"Select One"}
  8. ></ReactCustomSelector>

if you would like to use the selected value of react-custom-selector
you can do so like the example below

  1. this.state = {
  2. selected: ''
  3. }
  4. takeValue(selectValue){
  5. let self = this;
  6. if(selectValue && (selectValue == undefined || selectValue == 0)) {
  7. //do something
  8. self.setState({selected: ''});
  9. } else if (selectValue){
  10. //do somethng else
  11. self.setState({selected: selectValue});
  12. }
  13. }
  14. provide an array and your custom props
  15. let array = ['Amiee','Everett','Senaida','Genaro','Elsa'];
  16. you can obtain the selected value from this.state.selected
  17. <ReactCustomSelector
  18. options={array}
  19. placeholder={"Select One"}
  20. selectValue={this.takeValue}
  21. ></ReactCustomSelector>

Props

name description type default
className additional css class String ‘’
placeholder select placeholder React Node
name selector name String
noContentMsg show a message if there is no content to show String No Content Found
value current selected option Strng/Array

License

MIT License

Copyright (c) 2017

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Copyright (c) 2017 Marios Ledio Taso.