Skip to content

Commit b790d53

Browse files
committed
fix: prevent whole app from going blank when loading new pages
1 parent 2da4d7e commit b790d53

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/icons/icons.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import HelpSquareIcon from "@tabler/icons/outline/help-square.svg?raw";
2-
import { createContext, use } from "react";
2+
import { createContext, use, useRef } from "react";
33

44
const TABLER_ICONS_VERSION = "3.41.1";
55

@@ -8,7 +8,8 @@ type IconMap = Map<string, Promise<string>>;
88
const context = createContext<IconMap | null>(null);
99

1010
export function IconProvider({ children }: { children: React.ReactNode }) {
11-
return <context.Provider value={new Map()}>{children}</context.Provider>;
11+
const iconMap = useRef(new Map<string, Promise<string>>());
12+
return <context.Provider value={iconMap.current}>{children}</context.Provider>;
1213
}
1314

1415
export function useIcon(

src/routes/_app.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
useRouter,
66
useRouterState,
77
} from "@tanstack/react-router";
8+
import { Suspense, useEffect } from "react";
89
import { useAtomValue, useSetAtom } from "jotai";
9-
import { useEffect } from "react";
1010
import { AppBar } from "../components/AppBar";
1111
import { BottomNavigation } from "../components/BottomNavigation";
1212
import { DevBanner } from "../components/DevBanner";
@@ -78,7 +78,9 @@ function RouteComponent() {
7878
<AppBar />
7979

8080
<main className="flex-1 overflow-y-hidden">
81-
<Outlet />
81+
<Suspense>
82+
<Outlet />
83+
</Suspense>
8284
</main>
8385

8486
<BottomNavigation />

0 commit comments

Comments
 (0)