Skip to content

Commit

Permalink
fix: hydration on ssr pages (#4022)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariojsnunes authored Nov 27, 2024
1 parent 63fb203 commit fa10f7e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/routes/_.how-to.$slug._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ export async function loader({ params }: LoaderFunctionArgs) {
return json({ howto })
}

export function HydrateFallback() {
// This is required because all routes are loaded client-side. Avoids a page flicker before css is loaded.
// Can be removed once ALL pages are using SSR.
return <div></div>
}

export const meta = mergeMeta<typeof loader>(({ data }) => {
const howto = data?.howto as IHowtoDB

Expand Down
6 changes: 6 additions & 0 deletions src/routes/_.questions.$slug._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ export async function loader({ params }: LoaderFunctionArgs) {
return json({ question })
}

export function HydrateFallback() {
// This is required because all routes are loaded client-side. Avoids a page flicker before css is loaded.
// Can be removed once ALL pages are using SSR.
return <div></div>
}

export const meta = mergeMeta<typeof loader>(({ data }) => {
const question = data?.question as IQuestionDB

Expand Down
6 changes: 6 additions & 0 deletions src/routes/_.research.$slug._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export async function loader({ params }: LoaderFunctionArgs) {
return json({ research, publicUpdates })
}

export function HydrateFallback() {
// This is required because all routes are loaded client-side. Avoids a page flicker before css is loaded.
// Can be removed once ALL pages are using SSR.
return <div></div>
}

export const meta = mergeMeta<typeof loader>(({ data }) => {
const research = data?.research as IResearchDB
const publicUpdates = data?.publicUpdates as IResearch.UpdateDB[]
Expand Down
6 changes: 6 additions & 0 deletions src/routes/_.u.$id._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export async function loader({ params }: LoaderFunctionArgs) {
return json({ profile, userCreatedDocs: userCreatedDocs || [] })
}

export function HydrateFallback() {
// This is required because all routes are loaded client-side. Avoids a page flicker before css is loaded.
// Can be removed once ALL pages are using SSR.
return <div></div>
}

export const meta = mergeMeta<typeof loader>(({ data }) => {
const profile = data?.profile as IUserDB

Expand Down

0 comments on commit fa10f7e

Please sign in to comment.