Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search page hydration error #1670

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions frontends/main/src/app/search/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Suspense } from "react"
import React from "react"
import { getMetadataAsync } from "@/common/metadata"
import SearchPage from "@/app-pages/SearchPage/SearchPage"

Expand All @@ -13,12 +13,20 @@ export async function generateMetadata({
})
}

/**
* The search page uses Next's `useSearchParams`. This requires either:
* 1. wrap the <SearchPage /> in Suspense
* 2. or force-dynamic.
*
* (1) caused a hydration error for authenticated users. We haven not found
* the root cause of the hydration error.
*
* (2) seems to work well.
*/
export const dynamic = "force-dynamic"

const Page: React.FC = () => {
return (
<Suspense>
<SearchPage />
</Suspense>
)
return <SearchPage />
}

export default Page
Loading