As you can see here, I used useQuery() but I only want it to fetch once. Not sure if it is NextJS problem or react-query problem.
NextJS and react-query
1.1k views Asked by Kai Sheng Tung At
2
There are 2 answers
0
On
Without code is hard to evaluate, but this works fines for me in NextJS. Probably the problem is where you're calling useQuery
hook
function App (){
const { loading, error, data: { listCourses: courses } = {} } = useQuery(
listCourses(),
{
variables: { type: "online" },
}
);
return (
<Layout>
{something}
</Layout>
);
};
react-query
does query retries out of the box. See the docs here. It is possible to disable it, passing{ retry: false }
as options touseQuery()
hook.