⚙️ useful-state
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) |