-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b321ed6
commit 3c3a7fe
Showing
2 changed files
with
14 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
import { unstable_cache as next_unstable_cache } from "next/cache"; | ||
import { cache } from "react"; | ||
|
||
// sorry theo but we're using an any | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
type Callback<T> = (...args: any[]) => Promise<T>; | ||
|
||
// next_unstable_cache doesn't handle deduplication, so we wrap it in React's cache | ||
export const unstable_cache = <T>( | ||
callback: Callback<T>, | ||
export const unstable_cache = <Inputs extends unknown[], Output>( | ||
callback: (...args: Inputs) => Promise<Output>, | ||
key: string[], | ||
options: { revalidate: number }, | ||
) => cache(next_unstable_cache(callback, key, options)); |