Skip to content

Commit

Permalink
[cms-sanity] Fix hook being called conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Dec 17, 2020
1 parent 8edf408 commit 7e66a50
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions examples/cms-sanity/pages/posts/[slug].js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import {

export default function Post({ data, preview }) {
const router = useRouter()
if (!router.isFallback && !data.post?.slug) {
return <ErrorPage statusCode={404} />
}

const {
data: { post, morePosts },
Expand All @@ -33,6 +30,10 @@ export default function Post({ data, preview }) {
enabled: preview,
})

if (!router.isFallback && !data.post?.slug) {
return <ErrorPage statusCode={404} />
}

return (
<Layout preview={preview}>
<Container>
Expand Down

0 comments on commit 7e66a50

Please sign in to comment.