Skip to content

Commit

Permalink
feat(frontend): Add default error handling to queries and mutations (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
amanape authored Dec 2, 2024
1 parent d96118a commit 96c429d
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions frontend/src/entry.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import { hydrateRoot } from "react-dom/client";
import { Provider } from "react-redux";
import posthog from "posthog-js";
import "./i18n";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import {
QueryCache,
QueryClient,
QueryClientProvider,
} from "@tanstack/react-query";
import toast from "react-hot-toast";
import store from "./store";
import { useConfig } from "./hooks/query/use-config";
import { AuthProvider } from "./context/auth-context";
Expand Down Expand Up @@ -45,7 +50,20 @@ async function prepareApp() {
}
}

const queryClient = new QueryClient();
const queryClient = new QueryClient({
queryCache: new QueryCache({
onError: (error) => {
toast.error(error.message);
},
}),
defaultOptions: {
mutations: {
onError: (error) => {
toast.error(error.message);
},
},
},
});

prepareApp().then(() =>
startTransition(() => {
Expand Down

0 comments on commit 96c429d

Please sign in to comment.