Skip to content

Commit 3f7f27a

Browse files
committed
fix: add Suspense boundaries around profile page and publishers/new page to avoid hydration/build errors with useSearchParams.\n\n🤖 Generated with Codebuff\nCo-Authored-By: Codebuff <[email protected]>
1 parent 623b4cb commit 3f7f27a

File tree

2 files changed

+65
-4
lines changed

2 files changed

+65
-4
lines changed

web/src/app/profile/page.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { useState, useEffect } from 'react'
3+
import { useState, useEffect, Suspense } from 'react'
44
import { useSearchParams } from 'next/navigation'
55
import { useSession } from 'next-auth/react'
66
import { CreditCard, Shield, Users, Key, Menu } from 'lucide-react'
@@ -77,7 +77,7 @@ function ProfileSidebar({
7777
)
7878
}
7979

80-
export default function ProfilePage() {
80+
function ProfilePageContent() {
8181
const { status } = useSession()
8282
const searchParams = useSearchParams()
8383
const [activeSection, setActiveSection] = useState('usage')
@@ -195,3 +195,23 @@ export default function ProfilePage() {
195195
</div>
196196
)
197197
}
198+
199+
export default function ProfilePage() {
200+
return (
201+
<Suspense
202+
fallback={
203+
<div className="container mx-auto px-4 py-8">
204+
<div className="flex justify-center">
205+
<div className="w-full max-w-2xl space-y-4">
206+
<div className="h-8 w-64 bg-muted animate-pulse rounded" />
207+
<div className="h-4 w-96 bg-muted animate-pulse rounded" />
208+
<div className="h-64 w-full bg-muted animate-pulse rounded" />
209+
</div>
210+
</div>
211+
</div>
212+
}
213+
>
214+
<ProfilePageContent />
215+
</Suspense>
216+
)
217+
}

web/src/app/publishers/new/page.tsx

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { useState, useEffect } from 'react'
3+
import { useState, useEffect, Suspense } from 'react'
44
import { useQuery } from '@tanstack/react-query'
55
import { useDebounce } from 'use-debounce'
66
import { useRouter, useSearchParams } from 'next/navigation'
@@ -71,7 +71,7 @@ const buildSubmitPayload = (
7171
}
7272
}
7373

74-
const CreatePublisherPage = () => {
74+
const CreatePublisherPageContent = () => {
7575
const { data: session, status } = useSession()
7676
const router = useRouter()
7777
const searchParams = useSearchParams()
@@ -516,4 +516,45 @@ const CreatePublisherPage = () => {
516516
)
517517
}
518518

519+
const CreatePublisherPage = () => {
520+
return (
521+
<Suspense
522+
fallback={
523+
<div className="container mx-auto py-6 px-4">
524+
<div className="max-w-2xl mx-auto">
525+
<div className="flex items-center mb-8">
526+
<div className="h-8 w-20 mr-4 bg-muted animate-pulse rounded" />
527+
</div>
528+
<div className="flex items-center mb-8">
529+
<div className="h-8 w-8 rounded-full mr-3 bg-muted animate-pulse" />
530+
<div>
531+
<div className="h-8 w-64 mb-2 bg-muted animate-pulse rounded" />
532+
<div className="h-4 w-96 bg-muted animate-pulse rounded" />
533+
</div>
534+
</div>
535+
<Card>
536+
<CardHeader>
537+
<div className="h-6 w-48 bg-muted animate-pulse rounded" />
538+
</CardHeader>
539+
<CardContent>
540+
<div className="space-y-4">
541+
<div className="h-10 w-full bg-muted animate-pulse rounded" />
542+
<div className="h-10 w-full bg-muted animate-pulse rounded" />
543+
<div className="h-20 w-full bg-muted animate-pulse rounded" />
544+
<div className="flex justify-between pt-6">
545+
<div className="h-10 w-20 bg-muted animate-pulse rounded" />
546+
<div className="h-10 w-24 bg-muted animate-pulse rounded" />
547+
</div>
548+
</div>
549+
</CardContent>
550+
</Card>
551+
</div>
552+
</div>
553+
}
554+
>
555+
<CreatePublisherPageContent />
556+
</Suspense>
557+
)
558+
}
559+
519560
export default CreatePublisherPage

0 commit comments

Comments
 (0)