useControllableState
One hook that lets a component be driven from outside (`value` + `onChange`) or manage its own state (`defaultValue`), the same two-mode contract a native `<input>` has, while the component body only ever reads one value and calls one setter.
4 min read
#frontendA native <input> works two ways: pass value + onChange and you
own its state, or pass defaultValue and it owns its own.
useControllableState gives a custom component that same choice from
a single hook - the body just reads one value and calls one
setValue, and never has to branch on which mode it's in.
@itsnas color-picker.tsx
codecolor-picker.tsx
main
Nas (@itsnas)
main
Nas (@itsnas)