Replies: 2 comments
-
|
I'm not sure I understand the request,
export function AdminWidget() {
const admin = useRoute("routes/admin");
if (!admin) {
throw new Error(`AdminWidget used outside of "routes/admin"`);
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Indeed. I was mistaken and confused. Thanks for setting me straight! https://github.com/mw10013/oui/blob/1a443ec94b35fcb0e9da5595212b8c996e0958ff/app/root.tsx#L101-L117 export function Layout({ children }: { children: React.ReactNode }) {
const data = ReactRouter.unstable_useRoute("root");
return (
<RemixThemes.ThemeProvider
specifiedTheme={data.loaderData?.theme ?? null}
themeAction="/action/set-theme"
disableTransitionOnThemeChange
>
<Html
ssrTheme={Boolean(data.loaderData?.theme)}
isAnalyticsEnabled={Boolean(data.loaderData?.isAnalyticsEnabled)}
>
{children}
</Html>
</RemixThemes.ThemeProvider>
);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The docs for
Layoutdirect you to useuseRouteLoaderDatasinceLayoutmay be used with anErrorBoundaryand there may be no data due an error.useRouteLoaderDatareturnany.Ask for variation of
unstable_useRoutethat returns undefined if no data loaded. TheanyfromuseRouteLoaderDatacan make code a bit noisy. Would be great to have an actual type | undefined.https://github.com/mw10013/oui/blob/aca512998e117f6901b386557cc3052376ce201c/app/root.tsx#L101-L123
Beta Was this translation helpful? Give feedback.
All reactions