Prevent fetching article before router params have been read
This prevents us from making an initial fetch with an undefined slug and username that then returns a 400. This happens because router isn't setup when we first make the call.
This commit is contained in:
@ -677,10 +677,14 @@ export function useRefreshProcessingItems() {
|
|||||||
return mutation
|
return mutation
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useGetLibraryItemContent = (username: string, slug: string) => {
|
export const useGetLibraryItemContent = (
|
||||||
|
username: string | undefined,
|
||||||
|
slug: string | undefined
|
||||||
|
) => {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ['libraryItem', slug],
|
queryKey: ['libraryItem', slug],
|
||||||
|
enabled: !!username && !!slug,
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const response = (await gqlFetcher(GQL_GET_LIBRARY_ITEM_CONTENT, {
|
const response = (await gqlFetcher(GQL_GET_LIBRARY_ITEM_CONTENT, {
|
||||||
slug,
|
slug,
|
||||||
|
|||||||
Reference in New Issue
Block a user