Added AbortController to getRecipe params.
This commit is contained in:
parent
201ddb6656
commit
647a4be383
@ -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,
|
||||
|
@ -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({
|
||||
|
Loading…
Reference in New Issue
Block a user