Skip to content
Merged
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
52 changes: 50 additions & 2 deletions docs/components/Set.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
# Set

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

Send us a PR if you want to collaborate! :green_heart:
```js
import { Set } from 'react-powerplug'
```

```jsx
<Set initial={['react', 'babel']}>
{({ values, remove, add }) => (
<TagManager>
<FormInput onSubmit={add} />
{values.map(tag => (
<Tag onRemove={() => remove(tag)}>{tag}</Tag>
))}
</TagManager>
)}
</Set>
```

## Set Props

**initial = []** _(optional)_
Specifies the initial values state, must be an array. Duplicate items will be removed.
By default, the initial values state is an empty array.

**onChange** _(optional)_
The onChange event of the Set is called whenever the values state changes.

## Set Children Props

TL;DR: `{ values, add, clear, remove, has }`

**values**
`array`
Your values state, contains only unique items

**add**
`(value: any) => void`
Add a unique `value` to your values array. Does nothing if values array already includes a `value`.

**clear**
`() => any`
Reset values state to an empty array

**remove**
`(value: any) => void`
Remove a `value` from your values array

**has**
`(value: any) => boolean`
True if values array includes a `value`