mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-07 19:55:46 -05:00
More graceful 404's
This commit is contained in:
@@ -6,5 +6,5 @@ export function useUser() {
|
||||
const [root] = useMatches();
|
||||
invariant(root);
|
||||
|
||||
return (root.data as RootLoaderData).user;
|
||||
return (root.data as RootLoaderData | undefined)?.user;
|
||||
}
|
||||
|
||||
24
app/root.tsx
24
app/root.tsx
@@ -18,6 +18,7 @@ import commonStyles from "~/styles/common.css";
|
||||
import globalStyles from "~/styles/global.css";
|
||||
import layoutStyles from "~/styles/layout.css";
|
||||
import resetStyles from "~/styles/reset.css";
|
||||
import { Catcher } from "./components/Catcher";
|
||||
import { Layout } from "./components/layout";
|
||||
import type { UserWithPlusTier } from "./db/types";
|
||||
import { getUser } from "./modules/auth";
|
||||
@@ -61,7 +62,7 @@ export const loader: LoaderFunction = async ({ request }) => {
|
||||
});
|
||||
};
|
||||
|
||||
export default function App() {
|
||||
function Document({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
@@ -70,9 +71,7 @@ export default function App() {
|
||||
</head>
|
||||
<body>
|
||||
<React.StrictMode>
|
||||
<Layout>
|
||||
<Outlet />
|
||||
</Layout>
|
||||
<Layout>{children}</Layout>
|
||||
</React.StrictMode>
|
||||
<ScrollRestoration />
|
||||
<Scripts />
|
||||
@@ -81,3 +80,20 @@ export default function App() {
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<Document>
|
||||
<Outlet />
|
||||
</Document>
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: this shows user as logged out even if they are logged in - a bit awkward with 404's
|
||||
export function CatchBoundary() {
|
||||
return (
|
||||
<Document>
|
||||
<Catcher />
|
||||
</Document>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user