skip to Main Content

Javascript – How do I fix this error: Query data cannot be undefined. Please make sure to return a value other than undefined from your query function

I have the following code. import Post from "../post/Post"; import "./posts.scss"; import {useQuery} from "@tanstack/react-query"; import {makeRequest} from "../../axios"; //omitted code here const {isLoading, error, data } = useQuery({ queryKey: ["posts"], queryFn: () => { makeRequest.get("/posts").then((res) => { return;…


Reactjs – React-Query infinite retry loop

Facing an infinite render when a query fails using react-query. useQuery should only re-fetch if queryKey changes, or on request failure according to retry parameter. Why is queryFn being re-executed? Reproducible example: const queryClient = new QueryClient({ defaultOptions: {…

Back To Top