use-array-state
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

use-array-state

A simple helper to makes changes to an array without needing to worry about mutating the value

Install

npm install use-array-state

Useage

import useArrayState from 'use-array-state'
 
function ArrayComponent () {
  const [value, valueActions] = useArrayState()
 
  return (
    <div>
      <button onClick={() => {valueActions.push('new-value')}}
      <pre>
        {JSON.stringify(value, null, 2)}
      </pre>
    </div>
  )
}

Available actions

See src/index.ts for the the interface, all methods contain docs in types

Package Sidebar

Install

npm i use-array-state

Weekly Downloads

43

Version

1.0.2

License

MIT

Unpacked Size

22.5 kB

Total Files

10

Last publish

Collaborators

  • azmenak