fix: move useDocumentTitle before early returns (Rules of Hooks)
This commit is contained in:
@@ -30,12 +30,12 @@ function MovieDetailPage() {
|
||||
const { data, isPending } = useMovie(id)
|
||||
const { data: profile } = useMovieProfile(id)
|
||||
const { data: history } = useMovieHistory(id)
|
||||
useDocumentTitle(data?.movie.title)
|
||||
|
||||
if (isPending) return <DetailSkeleton />
|
||||
if (!data) return null
|
||||
|
||||
const { movie, stats, reviews } = data
|
||||
useDocumentTitle(movie.title)
|
||||
const hasStats = profile && (profile.budget_usd != null || profile.revenue_usd != null || profile.vote_average != null)
|
||||
|
||||
return (
|
||||
|
||||
@@ -17,12 +17,12 @@ function PersonDetailPage() {
|
||||
const { t } = useTranslation()
|
||||
const { id } = Route.useParams()
|
||||
const { data, isPending } = usePersonCredits(id)
|
||||
useDocumentTitle(data?.person.name)
|
||||
|
||||
if (isPending) return <PersonSkeleton />
|
||||
if (!data) return null
|
||||
|
||||
const { person, cast, crew } = data
|
||||
useDocumentTitle(person.name)
|
||||
|
||||
return (
|
||||
<div className="space-y-4 p-4">
|
||||
|
||||
@@ -25,11 +25,10 @@ function UserProfilePage() {
|
||||
const unfollowMutation = useUnfollow()
|
||||
|
||||
const [search, setSearch] = useState("")
|
||||
useDocumentTitle(data?.username)
|
||||
|
||||
if (isPending) return <ProfileSkeleton />
|
||||
if (!data) return null
|
||||
|
||||
useDocumentTitle(data?.username)
|
||||
const isSelf = auth?.user_id === id
|
||||
const isFollowing = followingData?.actors.some((a) => a.handle === data.username) ?? false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user