import React from "react"; import { Fn, IntersectionFn, Pipe, SetOptionalFn, ToSchema } from "../types/Fn"; import { Hoc } from "../types/Hoc"; interface WithStateFn extends Fn { return: Pipe>]>, SetOptionalFn, IntersectionFn ]>; } type WithStateHoc = }`, Props extends object = {}>(stateName: StateName, options?: { /** * the initial value * * @example * // initial state from a constant * {init: "initial value"} * * @example * // initial state will be derived from someProp * {init: ({ someProp }: {someProp: number}) => someProp + 1} */ init?: Exclude | ((props: Props) => PropValue); /** * the setter's name property, usually you want to the default which is `set${Capitalize}` * @default `set${Capitalize}` * @example * withState("someState", { * init: 0, * setterName: "setSomeState" // default * })(Example) */ setterName?: SetterName; }) => Hoc<[WithStateFn>]>; /** * like `useState` or you can pass properties to the component to make it controllable * @example * const CounterWithState = withState("count", { init: 0 })(function Counter({count, setCount}: {count: number; setCount: Dispatch>}) { * return ; * }); * // using CounterWithState as self controlled * function IndependentCounters() { * return <> * * * ; * } * // will render 2 buttons that can count independently * * // using CounterWithState as parent controlled * function SameCounters() { * const [count, setCount] = useState(0); * return <> * * * ; * } * // will render 2 buttons with the same count */ export declare const withState: WithStateHoc; export {}; //# sourceMappingURL=withState.d.ts.map