Nemo's Parental Misguidance
Miss any of our Open RFC calls?Watch the recordings here! »

use-array-state

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

Install

npm i use-array-state

DownloadsWeekly Downloads

6

Version

1.0.2

License

MIT

Unpacked Size

22.5 kB

Total Files

10

Last publish

Collaborators

  • avatar