Skip to content

Commit eb0489f

Browse files
denisborovikovTrySound
authored andcommitted
Add Set doc (#128)
Add <Set /> documentation
1 parent f1bf5a8 commit eb0489f

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

docs/components/Set.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
11
# Set
22

3-
// TODO: :disappointed_relieved:
3+
The Set component is used to work with an array of unique values.
44

5-
Send us a PR if you want to collaborate! :green_heart:
5+
```js
6+
import { Set } from 'react-powerplug'
7+
```
8+
9+
```jsx
10+
<Set initial={['react', 'babel']}>
11+
{({ values, remove, add }) => (
12+
<TagManager>
13+
<FormInput onSubmit={add} />
14+
{values.map(tag => (
15+
<Tag onRemove={() => remove(tag)}>{tag}</Tag>
16+
))}
17+
</TagManager>
18+
)}
19+
</Set>
20+
```
21+
22+
## Set Props
23+
24+
**initial = []** _(optional)_
25+
Specifies the initial values state, must be an array. Duplicate items will be removed.
26+
By default, the initial values state is an empty array.
27+
28+
**onChange** _(optional)_
29+
The onChange event of the Set is called whenever the values state changes.
30+
31+
## Set Children Props
32+
33+
TL;DR: `{ values, add, clear, remove, has }`
34+
35+
**values**
36+
`array`
37+
Your values state, contains only unique items
38+
39+
**add**
40+
`(value: any) => void`
41+
Add a unique `value` to your values array. Does nothing if values array already includes a `value`.
42+
43+
**clear**
44+
`() => any`
45+
Reset values state to an empty array
46+
47+
**remove**
48+
`(value: any) => void`
49+
Remove a `value` from your values array
50+
51+
**has**
52+
`(value: any) => boolean`
53+
True if values array includes a `value`

0 commit comments

Comments
 (0)