useful-state

1.2.4 • Public • Published

⚙️ useful-state

Status Coverage Status

Custom state hooks for simple UI goals.

useOpen

Use this to attach a ref to the open/close state of your UI component.

Methods Description
open Assign truthy value to isOpen property
close Assign falsy value to isOpen property

useToggle

Super similar to the hook above, only it ships with a toggle method and no refs.

Methods Description
open Assign truthy value to state
close Assign falsy value to state
toggle Inverts current state value

useValue

Most often used with inputs; provides an easy way to track value changes and manage focus.

Methods Description
onFocus Call the .focus() method on ref if it exists
onClear Clear state
onChange Assign target value to state (provide an event argument)

Readme

Keywords

none

Package Sidebar

Install

npm i useful-state

Weekly Downloads

10

Version

1.2.4

License

MIT

Unpacked Size

18.8 kB

Total Files

19

Last publish

Collaborators

  • 3merge