Skip to content

Updated README to include Usage Instructions for React 0.14+ #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,81 @@ An accessible select box component for React.
$ npm install react-select-box --save
```

## Usage
To add a single select box:

```JavaScript
import React from 'react';
import SelectBox from 'react-select-box';

var option = React.createElement.bind(null, 'option');

export default class Example extends React.Component {

constructor() {
super();
this.state = {
color: null
};
}

handleChange(color) {
this.setState({color});
}

render() {
return (
<div>
<SelectBox label="Favorite Color" onChange={this.handleChange.bind(this)} value={this.state.color}>
<option value={'red'}>Red</option>
<option value={'green'}>Green</option>
<option value={'blue'}>Blue</option>
</SelectBox>
</div>
);
}

}

```

To add a multi select box:

```JavaScript
import React from 'react';
import SelectBox from 'react-select-box';

var option = React.createElement.bind(null, 'option');

export default class Example extends React.Component {

constructor() {
super();
this.state = {
colors: []
};
}

handleMultiChange(colors) {
this.setState({colors});
}

render() {
return (
<div>
<SelectBox label="Favorite Colors" onChange={this.handleMultiChange.bind(this)} value={this.state.colors} multiple={true}>
<option value={'red'}>Red</option>
<option value={'green'}>Green</option>
<option value={'blue'}>Blue</option>
</SelectBox>
</div>
);
}

}

```

## Development

```bash
Expand Down