Skip to content

Instantly share code, notes, and snippets.

@efkann
Created October 10, 2023 20:00
Show Gist options
  • Save efkann/7516af92aaf5daea1d42295b830eac84 to your computer and use it in GitHub Desktop.
Save efkann/7516af92aaf5daea1d42295b830eac84 to your computer and use it in GitHub Desktop.
React Experimental Hooks Type Declarations
declare module 'react-dom' {
interface FormStatusNotPending {
pending: false;
data: null;
method: null;
action: null;
}
interface FormStatusPending {
pending: true;
data: FormData;
method: string;
action: string | ((formData: FormData) => void | Promise<void>);
}
type FormStatus = FormStatusPending | FormStatusNotPending;
function experimental_useFormStatus(): FormStatus;
function experimental_useFormState<State>(
action: (state: State) => Promise<State>,
initialState: State,
permalink?: string
): [state: State, dispatch: () => void];
function experimental_useFormState<State, Payload>(
action: (state: State, payload: Payload) => Promise<State>,
initialState: State,
permalink?: string
): [state: State, dispatch: (payload: Payload) => void];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment