add error boundary to the app root

This commit is contained in:
jeffvli
2025-11-16 21:53:43 -08:00
parent 4451389b6a
commit 199a67fdf3
2 changed files with 117 additions and 25 deletions
+28 -25
View File
@@ -7,6 +7,7 @@ import { del, get, set } from 'idb-keyval';
import { createRoot } from 'react-dom/client';
import { App } from '/@/renderer/app';
import { RootErrorBoundary } from '/@/renderer/components/error-boundary/root-error-boundary';
import { queryClient } from '/@/renderer/lib/react-query';
function createIDBPersister(idbValidKey: IDBValidKey = 'reactQuery') {
@@ -26,32 +27,34 @@ function createIDBPersister(idbValidKey: IDBValidKey = 'reactQuery') {
const indexedDbPersister = createIDBPersister('feishin');
createRoot(document.getElementById('root')!).render(
<PersistQueryClientProvider
client={queryClient}
persistOptions={{
buster: 'feishin',
dehydrateOptions: {
shouldDehydrateQuery: (query) => {
const isSuccess = query.state.status === 'success';
const isLyricsQueryKey =
query.queryKey.includes('song') &&
query.queryKey.includes('lyrics') &&
query.queryKey.includes('select');
<RootErrorBoundary>
<PersistQueryClientProvider
client={queryClient}
persistOptions={{
buster: 'feishin',
dehydrateOptions: {
shouldDehydrateQuery: (query) => {
const isSuccess = query.state.status === 'success';
const isLyricsQueryKey =
query.queryKey.includes('song') &&
query.queryKey.includes('lyrics') &&
query.queryKey.includes('select');
return isSuccess && isLyricsQueryKey;
},
},
hydrateOptions: {
defaultOptions: {
queries: {
gcTime: Infinity,
return isSuccess && isLyricsQueryKey;
},
},
},
maxAge: Infinity,
persister: indexedDbPersister,
}}
>
<App />
</PersistQueryClientProvider>,
hydrateOptions: {
defaultOptions: {
queries: {
gcTime: Infinity,
},
},
},
maxAge: Infinity,
persister: indexedDbPersister,
}}
>
<App />
</PersistQueryClientProvider>
</RootErrorBoundary>,
);