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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    46
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    46
  • 1.0.1
    0

Package Sidebar

Install

npm i use-array-state

Weekly Downloads

42

Version

1.0.2

License

MIT

Unpacked Size

22.5 kB

Total Files

10

Last publish

Collaborators

  • azmenak