type TState = [T, (fn: () => void) => void]; /** * Creates local component-level reactive state from a plain object. * * - Must be called inside a component function (restricted context check via `atom()`). * - Returns `[wrapper, update]` where: * - `wrapper` is a read-tracked proxy built by `wrapStateFunctions` — reads on data * properties automatically subscribe the component (or any enclosing `memo`/`effect`) * to re-run when the state changes. * - `update` is `a.update` — the raw handle for batched external mutations. * - Methods defined on the state object are automatically wrapped to call `a.update()` * internally, so calling a method (e.g. `state.incr()`) triggers reactivity without * needing to call `update()` manually. * - Direct property assignment on `wrapper` also triggers reactivity: * `wrapper.count = 5` is equivalent to `update(s => { s.count = 5; })`. * - The state instance is registered on `host._useStates` for devtools inspection. * * @param stateObj - A plain object (with optional methods and getters) that defines * the initial state shape. * @returns A tuple `[wrapper, update]`. * * @example * // 1. Using update() explicitly with inline mutations: * const counter = (props: PropsType<{}>) => { * const [state, update] = useState({ count: 0 }); * * return html` *
*

Count: ${state.count}

* *
* `; * }; * * @example * // 2. Using methods on the state object (no explicit update() needed): * const counter = (props: PropsType<{}>) => { * const [state] = useState({ * count: 0, * incr() { this.count++; }, * get doubled() { return this.count * 2; }, * }); * * return html` *
*

Count: ${state.count} (doubled: ${state.doubled})

* *
* `; * }; */ export declare const useState: (stateObj: T) => TState; export {}; //# sourceMappingURL=useState.d.ts.map