Skip to content

Latest commit

 

History

History

use.valuesstate

@rcp/use.valuesstate

NPM version NPM Downloads

The useful methods exported for values state

Installation

npm install @rcp/use.valuesstate
# or use yarn
yarn add @rcp/use.valuesstate

API

ValuesHelper

Type: Object

Parameters

  • values {T[]}
  • setValues {(values: T[]) => void}
  • remove {(value: T) => void}
  • add {(value: T) => void}
  • toggle {(value: T) => void}
  • indexOf {(value: T) => number}
  • has {(value: T) => boolean}

useValuesHelper

Parameters

  • stateValues {T[]}
  • setValues {(values: T[]) => void}

Returns ValuesHelper

useValuesState

Parameters

  • values {any[]}

Examples

import useValuesState from '@rcp/use.valuesstate'

function App() {
   const {values, add, remove} = useValuesState([])
   return <button onClick={() => add('something')}>Add</button>
}

Returns ValuesHelper

Related

Authors

This library is written and maintained by imcuttle, [email protected].

License

MIT