useToggleMany - custom react hook
Install:
With yarn:
yarn add use-toggle-many -S
With npm:
npm i use-toggle-many -S
Api:
const handleActive isActive active handleMany =
handleActive: (idOrIndex: string | number) => void
isActive: (idOrIndex: string | number) => boolean
active: Array<string | number>
handleMany: (arr: (string | number)[]) => void
arr?: (number | string)[]
Demos
Basic usage: demo
With initiall values set and optionall variable active
used: demo
With "clear all" and "update many at once" buttons: demo
Examples
Basic:
{ const handleActive isActive = return <div> <ul> fruits </ul> </div> }
With initiallState
and active variable used
:
{ const handleActive isActive active = return <div> <ul> "INLOVEWITHHOOKS" </ul> <p>Currently active: activelength</p> </div> }
With "clear all" and "update many at once" buttons:
{ const handleActive isActive active handleMany = ; return <div> <ul> fruits </ul> <button onClick= >Clear all</button> <button onClick= > Set Grapefruit & Blueberries </button> </div> ;}