fix: move useDocumentTitle before early returns (Rules of Hooks)

This commit is contained in:
2026-06-11 12:59:13 +02:00
parent 5dc90724d3
commit 21cc6ed437
3 changed files with 3 additions and 4 deletions

View File

@@ -30,12 +30,12 @@ function MovieDetailPage() {
const { data, isPending } = useMovie(id) const { data, isPending } = useMovie(id)
const { data: profile } = useMovieProfile(id) const { data: profile } = useMovieProfile(id)
const { data: history } = useMovieHistory(id) const { data: history } = useMovieHistory(id)
useDocumentTitle(data?.movie.title)
if (isPending) return <DetailSkeleton /> if (isPending) return <DetailSkeleton />
if (!data) return null if (!data) return null
const { movie, stats, reviews } = data const { movie, stats, reviews } = data
useDocumentTitle(movie.title)
const hasStats = profile && (profile.budget_usd != null || profile.revenue_usd != null || profile.vote_average != null) const hasStats = profile && (profile.budget_usd != null || profile.revenue_usd != null || profile.vote_average != null)
return ( return (

View File

@@ -17,12 +17,12 @@ function PersonDetailPage() {
const { t } = useTranslation() const { t } = useTranslation()
const { id } = Route.useParams() const { id } = Route.useParams()
const { data, isPending } = usePersonCredits(id) const { data, isPending } = usePersonCredits(id)
useDocumentTitle(data?.person.name)
if (isPending) return <PersonSkeleton /> if (isPending) return <PersonSkeleton />
if (!data) return null if (!data) return null
const { person, cast, crew } = data const { person, cast, crew } = data
useDocumentTitle(person.name)
return ( return (
<div className="space-y-4 p-4"> <div className="space-y-4 p-4">

View File

@@ -25,11 +25,10 @@ function UserProfilePage() {
const unfollowMutation = useUnfollow() const unfollowMutation = useUnfollow()
const [search, setSearch] = useState("") const [search, setSearch] = useState("")
useDocumentTitle(data?.username)
if (isPending) return <ProfileSkeleton /> if (isPending) return <ProfileSkeleton />
if (!data) return null if (!data) return null
useDocumentTitle(data?.username)
const isSelf = auth?.user_id === id const isSelf = auth?.user_id === id
const isFollowing = followingData?.actors.some((a) => a.handle === data.username) ?? false const isFollowing = followingData?.actors.some((a) => a.handle === data.username) ?? false