Skip to content

Commit

Permalink
Prevents going over githubapi limit to quickly
Browse files Browse the repository at this point in the history
  • Loading branch information
remko48 committed Oct 25, 2023
1 parent 5c733ac commit c831215
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pwa/src/hooks/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ export const useMarkdown = () => {
const API: APIService | null = React.useContext(APIContext);

const getContent = (filePath: string) =>
useQuery<any, Error>(["contents", filePath], () => API?.Markdown.getContent(filePath), {
useQuery<any, Error>({
queryKey: ["contents", filePath],
queryFn: () => API?.Markdown.getContent(filePath),
onError: (error) => {
console.warn(error.message);
},
refetchOnWindowFocus: false,
refetchOnMount: false,
refetchOnReconnect: false,
retry: 1,
retryDelay: 2000,
staleTime: 1000 * 60 * 60, // one hour
});

return { getContent };
Expand Down

0 comments on commit c831215

Please sign in to comment.