Skip to content

Commit

Permalink
Move type declaration into details/summary
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Aug 11, 2023
1 parent e00cac7 commit 0d5dacf
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions docs/route/should-revalidate.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@ new: true

# `shouldRevalidate`

<details>
<summary>Type declaration</summary>

```ts
interface ShouldRevalidateFunction {
(args: ShouldRevalidateFunctionArgs): boolean;
}

interface ShouldRevalidateFunctionArgs {
currentUrl: URL;
currentParams: AgnosticDataRouteMatch["params"];
nextUrl: URL;
nextParams: AgnosticDataRouteMatch["params"];
formMethod?: Submission["formMethod"];
formAction?: Submission["formAction"];
formEncType?: Submission["formEncType"];
text?: Submission["text"];
formData?: Submission["formData"];
json?: Submission["json"];
actionResult?: any;
defaultShouldRevalidate: boolean;
}
```

</details>

This function allows you opt-out of revalidation for a route's loader as an optimization.

<docs-warning>This feature only works if using a data router, see [Picking a Router][pickingarouter]</docs-warning>
Expand Down Expand Up @@ -53,27 +79,6 @@ Note that this is only for data that has already been loaded, is currently rende

<docs-warning>Using this API risks your UI getting out of sync with your data, use with caution!</docs-warning>

## Type Declaration

```ts
interface ShouldRevalidateFunction {
(args: {
currentUrl: URL;
currentParams: AgnosticDataRouteMatch["params"];
nextUrl: URL;
nextParams: AgnosticDataRouteMatch["params"];
formMethod?: Submission["formMethod"];
formAction?: Submission["formAction"];
formEncType?: Submission["formEncType"];
formData?: Submission["formData"];
json?: Submission["json"];
text?: Submission["text"];
actionResult?: any;
defaultShouldRevalidate: boolean;
}): boolean;
}
```

[action]: ./action
[form]: ../components/form
[fetcher]: ../hooks/use-fetcher
Expand Down

0 comments on commit 0d5dacf

Please sign in to comment.