mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-15 04:51:06 +02:00
add error boundary to the app root
This commit is contained in:
+28
-25
@@ -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>,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user