1.0.1 • Published 4 years ago

@feizheng/react-select v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

react-select

Pure select for react.

installation

npm install -S @feizheng/react-select

update

npm update @feizheng/react-select

properties

propertytypedefaultdescription
classNameString--
value---
onChange---

usage

  1. import css

    @import "~@feizheng/react-select/dist/style.scss";
    
    // customize your styles:
    $react-select-options: ()
  2. import js

    import ReactSelect from '../src/main';
    import ReactDOM from 'react-dom';
    import React from 'react';
    import './assets/style.scss';
    
    class App extends React.Component {
      state = {
        items: [
          {
            label: 'optino1',
            value: 'v1'
          },
          {
            label: 'optino2',
            value: 'v2'
          },
          {
            label: 'optino3',
            value: 'v3'
          }
        ]
      };
    
      constructor(inProps) {
        super(inProps);
        this.onChange = this.onChange.bind(this);
      }
    
      onChange(inEvent) {
        console.log('value:', inEvent.target.value);
      }
    
      render() {
        return (
          <div className="app-container">
            <p>
              <ReactSelect
                defaultValue={['v1']}
                multiple
                items={this.state.items}
                onChange={this.onChange}
              />
            </p>
    
            <p>
              <ReactSelect
                defaultValue="v2"
                items={this.state.items}
                onChange={this.onChange}
              />
            </p>
          </div>
        );
      }
    }
    
    ReactDOM.render(<App />, document.getElementById('app'));

documentation