From cf826cef2f84ab99c7dbb24ff556b507a3e01afe Mon Sep 17 00:00:00 2001 From: Aditya Srinivasan Date: Sun, 21 Aug 2016 00:45:58 +0530 Subject: [PATCH] Updated README to include usage for React 0.14+ --- README.md | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/README.md b/README.md index cd44ff0..7e5e738 100644 --- a/README.md +++ b/README.md @@ -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 ( +
+ + + + + +
+ ); + } + +} + +``` + +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 ( +
+ + + + + +
+ ); + } + +} + +``` + ## Development ```bash