Added AbortController to getRecipe params.

This commit is contained in:
Jesse Brault 2024-07-31 13:14:01 -05:00
parent 201ddb6656
commit 647a4be383
2 changed files with 14 additions and 2 deletions

View File

@ -3,6 +3,13 @@ import { ApiError } from './ApiError'
import FullRecipeView, { RawFullRecipeView } from './types/FullRecipeView'
import { toImageView } from './types/ImageView'
export interface GetRecipeDeps {
token: string | null
username: string
slug: string
abortController: AbortController
}
const getRecipe = async (
token: string | null,
ownerUsername: string,

View File

@ -7,11 +7,16 @@ import getRecipe from '../../api/getRecipe'
import Recipe from '../../pages/recipe/Recipe'
export const Route = createFileRoute('/recipes/$username/$slug')({
loader: ({ context, params }) =>
loader: ({ abortController, context, params }) =>
context.queryClient.ensureQueryData({
queryKey: ['recipe', params.username, params.slug],
queryFn: () =>
getRecipe(context.auth.token, params.username, params.slug)
getRecipe({
abortController,
token: context.auth.token,
username: params.username,
slug: params.slug
})
}),
component() {
const recipe = useLoaderData({