Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fetcher.submit types #11631

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add Shared types
  • Loading branch information
brophdawg11 committed Jun 13, 2024
commit 4120ae8fd6cc1bc3be4d9e8769eb32a8ee0d7554
13 changes: 12 additions & 1 deletion packages/react-router-dom/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ function isFormDataSubmitterSupported() {
return _formDataSupportsSubmitter;
}

export interface FetcherSubmitOptions {
/**
* Submit options shared by both navigations and fetchers
*/
interface SharedSubmitOptions {
/**
* The HTTP method used to submit the form. Overrides `<form method>`.
* Defaults to "GET".
Expand Down Expand Up @@ -188,6 +191,14 @@ export interface FetcherSubmitOptions {
unstable_flushSync?: boolean;
}

/**
* Submit options available to fetchers
*/
export interface FetcherSubmitOptions extends SharedSubmitOptions {}

/**
* Submit options available to navigations
*/
export interface SubmitOptions extends FetcherSubmitOptions {
/**
* Set `true` to replace the current entry in the browser's history stack
Expand Down
16 changes: 13 additions & 3 deletions packages/react-router-dom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,10 @@ if (__DEV__) {
NavLink.displayName = "NavLink";
}

export interface FetcherFormProps
extends React.FormHTMLAttributes<HTMLFormElement> {
/**
* Form props shared by navigations and fetchers
*/
interface SharedFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
/**
* The HTTP verb to use when the form is submit. Supports "get", "post",
* "put", "delete", "patch".
Expand Down Expand Up @@ -1201,7 +1203,15 @@ export interface FetcherFormProps
onSubmit?: React.FormEventHandler<HTMLFormElement>;
}

export interface FormProps extends FetcherFormProps {
/**
* Form props available to fetchers
*/
export interface FetcherFormProps extends SharedFormProps {}

/**
* Form props available to navigations
*/
export interface FormProps extends SharedFormProps {
/**
* Indicate a specific fetcherKey to use when using navigate=false
*/
Expand Down