Skip to content

Commit

Permalink
useSiteLoaderData always return site object
Browse files Browse the repository at this point in the history
  • Loading branch information
pogseal committed Aug 30, 2024
1 parent 1b35982 commit d98b7be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 0 additions & 2 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ function App() {
const theme = useTheme();

useChangeLanguage(locale);

//site data should live in layout, this may be potentially brittle if we shift site architecture around
const { site } = useSiteLoaderData();

// Hook to show the toasts
Expand Down
6 changes: 5 additions & 1 deletion app/utils/useSiteLoaderData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ export function useSiteLoaderData() {
// return useRouteLoaderData<typeof loader>("routes/_site+/_layout")!

// more brittle since we're using the layout hierarchy
return useMatches()?.[1]?.data as SerializeFrom<typeof layoutLoaderType>;
return (
(useMatches()?.[1]?.data as SerializeFrom<typeof layoutLoaderType>) ?? {
site: undefined,
}
);
}

0 comments on commit d98b7be

Please sign in to comment.