UNPKG

578 BTypeScriptView Raw
1import * as React from 'react';
2
3type GetFn<T> = (state: T) => React.ReactNode;
4type PrevState<T> = (prevState: T) => T;
5
6
7interface State<T> {
8 Ctx: (
9 fn: GetFn<S> | {children: (state: T) => React.ReactNode}
10 ) => React.ReactNode;
11 Put: (nextState: T | PrevState<T>) => void;
12 Val: <S = any>(
13 selector: (state: T) => S
14 ) => (fn: GetFn<S>) => React.ReactNode;
15 Auto: <S = any>(
16 selector: (state: T) => S
17 ) => (
18 fn: GetFn<S> | {children: (state: S) => React.ReactNode}
19 ) => React.ReactNode;
20}
21
22export function init<T = any>(initial: T = {}): State<T>;