1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | import React = require(".");
|
27 |
|
28 | export {};
|
29 |
|
30 | declare const UNDEFINED_VOID_ONLY: unique symbol;
|
31 | type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
|
32 |
|
33 | declare module "." {
|
34 | interface ThenableImpl<T> {
|
35 | then(onFulfill: (value: T) => unknown, onReject: (error: unknown) => unknown): void | PromiseLike<unknown>;
|
36 | }
|
37 | interface UntrackedThenable<T> extends ThenableImpl<T> {
|
38 | status?: void;
|
39 | }
|
40 |
|
41 | export interface PendingThenable<T> extends ThenableImpl<T> {
|
42 | status: "pending";
|
43 | }
|
44 |
|
45 | export interface FulfilledThenable<T> extends ThenableImpl<T> {
|
46 | status: "fulfilled";
|
47 | value: T;
|
48 | }
|
49 |
|
50 | export interface RejectedThenable<T> extends ThenableImpl<T> {
|
51 | status: "rejected";
|
52 | reason: unknown;
|
53 | }
|
54 |
|
55 | export type Thenable<T> = UntrackedThenable<T> | PendingThenable<T> | FulfilledThenable<T> | RejectedThenable<T>;
|
56 |
|
57 | export type Usable<T> = Thenable<T> | Context<T>;
|
58 |
|
59 | export function use<T>(usable: Usable<T>): T;
|
60 |
|
61 | interface ServerContextJSONArray extends ReadonlyArray<ServerContextJSONValue> {}
|
62 | export type ServerContextJSONValue =
|
63 | | string
|
64 | | boolean
|
65 | | number
|
66 | | null
|
67 | | ServerContextJSONArray
|
68 | | { [key: string]: ServerContextJSONValue };
|
69 | export interface ServerContext<T extends ServerContextJSONValue> {
|
70 | Provider: Provider<T>;
|
71 | }
|
72 | |
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | function useContext<T extends ServerContextJSONValue>(context: ServerContext<T>): T;
|
80 | export function createServerContext<T extends ServerContextJSONValue>(
|
81 | globalName: string,
|
82 | defaultValue: T,
|
83 | ): ServerContext<T>;
|
84 |
|
85 |
|
86 | export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
|
87 |
|
88 | export function unstable_useCacheRefresh(): () => void;
|
89 |
|
90 | interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS {
|
91 | functions: (formData: FormData) => void;
|
92 | }
|
93 |
|
94 | export interface TransitionStartFunction {
|
95 | |
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 | (callback: () => Promise<VoidOrUndefinedOnly>): void;
|
103 | }
|
104 |
|
105 | export function useOptimistic<State>(
|
106 | passthrough: State,
|
107 | ): [State, (action: State | ((pendingState: State) => State)) => void];
|
108 | export function useOptimistic<State, Action>(
|
109 | passthrough: State,
|
110 | reducer: (state: State, action: Action) => State,
|
111 | ): [State, (action: Action) => void];
|
112 |
|
113 | interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES {
|
114 | cleanup: () => VoidOrUndefinedOnly;
|
115 | }
|
116 |
|
117 | export function useActionState<State>(
|
118 | action: (state: Awaited<State>) => State | Promise<State>,
|
119 | initialState: Awaited<State>,
|
120 | permalink?: string,
|
121 | ): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
|
122 | export function useActionState<State, Payload>(
|
123 | action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
|
124 | initialState: Awaited<State>,
|
125 | permalink?: string,
|
126 | ): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
|
127 | }
|