A Readable useToggle
A boolean `useState` that hands back `on` / `off` / `toggle` instead of a raw setter, so call sites read as intent. Every function, and the controls object itself, stays referentially stable, safe to pass as props or list as effect dependencies without retriggering anything downstream.
4 min read
#frontenduseState(false) gives you setValue, so every call site ends up
spelling out setValue(true), setValue(false), setValue(v => !v).
Wrap it once instead, and the intent - on, off, toggle - moves
to the call site. The setters and the object holding them stay stable
across renders, so they pass cleanly as props or effect deps.
@itsnas panel.tsx
codepanel.tsx
main
Nas (@itsnas)
main
Nas (@itsnas)