Skip to content

Commit

Permalink
router updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jimniels committed Jan 8, 2025
1 parent 8954f57 commit aa010e8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
11 changes: 1 addition & 10 deletions quadratic-client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
import '@/index.css';
import '@/shared/shadcn/styles.css';

import { QuadraticLoading } from '@/app/ui/loading/QuadraticLoading';
import { router } from '@/router';
import { ShowAfter } from '@/shared/components/ShowAfter';
import * as Sentry from '@sentry/react';
import React from 'react';
import { createRoot } from 'react-dom/client';
Expand All @@ -31,13 +29,6 @@ const container = document.getElementById('root');
const root = createRoot(container as HTMLElement);
root.render(
<React.StrictMode>
<RouterProvider
router={router}
fallbackElement={
<ShowAfter delay={2000}>
<QuadraticLoading />
</ShowAfter>
}
/>
<RouterProvider router={router} future={{ v7_startTransition: true }} />
</React.StrictMode>
);
1 change: 1 addition & 0 deletions quadratic-client/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const router = createBrowserRouter(
loader={RootRoute.loader}
Component={RootRoute.Component}
ErrorBoundary={RootRoute.ErrorBoundary}
HydrateFallback={RootRoute.HydrateFallback}
>
<Route path="file">
{/* Check that the browser is supported _before_ we try to load anything from the API */}
Expand Down
10 changes: 10 additions & 0 deletions quadratic-client/src/routes/_root.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { QuadraticLoading } from '@/app/ui/loading/QuadraticLoading';
import { User, authClient } from '@/auth/auth';
import { Empty } from '@/dashboard/components/Empty';
import { GlobalSnackbarProvider } from '@/shared/components/GlobalSnackbarProvider';
import { MuiTheme } from '@/shared/components/MuiTheme';
import { ShowAfter } from '@/shared/components/ShowAfter';
import { ROUTE_LOADER_IDS } from '@/shared/constants/routes';
import { ThemeAccentColorEffects } from '@/shared/hooks/useThemeAccentColor';
import { ThemeAppearanceModeEffects } from '@/shared/hooks/useThemeAppearanceMode';
Expand Down Expand Up @@ -41,6 +43,14 @@ export const Component = () => {
);
};

export const HydrateFallback = () => {
return (
<ShowAfter delay={2000}>
<QuadraticLoading />
</ShowAfter>
);
};

export const ErrorBoundary = () => {
let error = useRouteError();
console.error(error);
Expand Down

0 comments on commit aa010e8

Please sign in to comment.