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, 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 (
|
||||||
|
|||||||
@@ -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">
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user