useControllableState
统一管理受控与非受控状态。
Signature
useControllableState<T>(params): [T, setter]Parameters
| Name | Type | Description |
|---|---|---|
value | T | undefined | Controlled value; when set, internal state is bypassed. |
defaultValue | T | undefined | Initial value for the uncontrolled case. |
onChange | (value: T) => void | Called on every change (controlled or not). |
Returns
[value, setValue] — setValue accepts a value or functional updater.
SSR notes
Safe in Client Components. Uncontrolled defaultValue is fixed after first render.
Import
import { useControllableState } from "@gunkin/uiify/hooks";