/use-state-as-array

Define multiple react state as an array.

Primary LanguageTypeScriptGNU General Public License v3.0GPL-3.0

useStateAsArray react hook

npm

A React Hook to create multiple react useState states as an array.


Installation


Installation

$ yarn add use-state-as-array

Import

import useStateAsArray from 'use-state-as-array';

Usage

const [stateAsArray, setStateAsArray] = useStateAsArray(['first', 'second'])

setStateAsArray(0, 'new value')