Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 19a6d69

Browse files
authored
Adding a simple example of using MultiSelect
1 parent 0fc7fc6 commit 19a6d69

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

README.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,38 @@ React Multi Select Component
88

99
## Installation:
1010
`npm install --save @khanacademy/react-multi-select`
11+
`yarn add @khanacademy/react-multi-select`
1112

1213
## Usage:
13-
See the examples in ``/src/stories/index.js` for how to use the component
14+
See the examples in `/src/stories/index.js` for how to use the component, but here is a minimum required setups:
15+
16+
```
17+
import React from 'react';
18+
import MultiSelect from "@khanacademy/react-multi-select";
19+
20+
const options = [
21+
{label: "One", value: 1},
22+
{label: "Two", value: 2},
23+
{label: "Three", value: 3},
24+
];
25+
26+
class Consumer extends React.Component {
27+
state = {
28+
selected: [],
29+
}
30+
31+
render() {
32+
const {selected} = this.state;
33+
34+
return <MultiSelect
35+
options={options}
36+
selected={selected}
37+
onSelectedChanged={selected => this.setState({selected})}
38+
/>
39+
}
40+
}
41+
```
42+
1443

1544
## i18n:
1645
You can override the strings to be whatever you want, including translations for your languages.

0 commit comments

Comments
 (0)