--- name: List menu: 1. State Containers --- import { Props, Prop, ChildrenProps, ChildrenProp } from '../_ui/PropsTable' import { List } from '../../dist/react-powerplug.esm' # List The List component is used to work with an array. *For unique arrays see Set.* ## Usage ```js import { List } from 'react-powerplug' ``` ```jsx {({ list, pull, push }) => (
{list.map(({ tag }) => ( pull(value => value === tag)}> {tag} ))}
)}
``` ## Props Specifies the initial `list` state. The onChange event of the List is called whenever the `list` state changes. Receive state as function. It can also be `render` prop. ## Children Props Your `list` state value Get first element of your `list` array Get last element of your `list` array Add one or more items to your `list` array Remove an item based on a predicate function.
All matched items are removed.
Use Array.prototype.sort{' '} to sort your `list` state. Set a new full `list` array to your state Reset `list` to initial state