working on hot reloading

This commit is contained in:
2024-08-26 16:30:29 -06:00
parent 0af6ffa8f5
commit f7e13fb6aa
11 changed files with 57 additions and 88 deletions

View File

@@ -38,8 +38,8 @@ export const fileStorageService = {
async directoryExists(directoryPath: string): Promise<boolean> {
try {
const stat = await fs.stat(directoryPath);
return stat.isDirectory();
await fs.access(directoryPath);
return true;
} catch {
return false;
}

View File

@@ -9,15 +9,18 @@ import React from "react";
import { FC, ReactNode, useState } from "react";
import { createQueryClient } from "./queryClient";
export const MyQueryClientProvider: FC<{
export default function MyQueryClientProvider({
children,
dehydratedState,
}: {
children: ReactNode;
dehydratedState: DehydratedState;
}> = ({ children, dehydratedState }) => {
}) {
const [queryClient] = useState(createQueryClient());
hydrate(queryClient, dehydratedState);
return (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
);
};
}

View File

@@ -123,21 +123,23 @@ export function createSuccessToast(message: string) {
);
}
export const createQueryClient = () => new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
retry: 0,
export function createQueryClient() {
return new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
retry: 0,
},
mutations: {
onError: addErrorAsToast,
retry: 0,
},
},
mutations: {
queryCache: new QueryCache({
onError: addErrorAsToast,
retry: 0,
},
},
queryCache: new QueryCache({
onError: addErrorAsToast,
}),
mutationCache: new MutationCache({
onError: addErrorAsToast,
}),
});
}),
mutationCache: new MutationCache({
onError: addErrorAsToast,
}),
});
}

View File

@@ -1,20 +1,22 @@
import { MutationCache, QueryCache, QueryClient } from "@tanstack/react-query";
export const createQueryClientForServer = () => new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
retry: 0,
export function createQueryClientForServer() {
return new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
retry: 0,
},
mutations: {
onError: (e) => console.log(e),
retry: 0,
},
},
mutations: {
queryCache: new QueryCache({
onError: (e) => console.log(e),
retry: 0,
},
},
queryCache: new QueryCache({
onError: (e) => console.log(e),
}),
mutationCache: new MutationCache({
onError: (e) => console.log(e),
}),
});
}),
mutationCache: new MutationCache({
onError: (e) => console.log(e),
}),
});
}