Skip to content

Commit

Permalink
Remove unstable_ prefix from unstable_notFound
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Oct 27, 2020
1 parent 4782bda commit 75122e3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
20 changes: 12 additions & 8 deletions packages/next/next-server/server/render.tsx
Expand Up @@ -625,7 +625,7 @@ export async function renderToHTML(
key !== 'revalidate' &&
key !== 'props' &&
key !== 'unstable_redirect' &&
key !== 'unstable_notFound'
key !== 'notFound'
)

if (invalidKeys.includes('unstable_revalidate')) {
Expand All @@ -636,10 +636,10 @@ export async function renderToHTML(
throw new Error(invalidKeysMsg('getStaticProps', invalidKeys))
}

if (data.unstable_notFound) {
if (data.notFound) {
if (pathname === '/404') {
throw new Error(
`The /404 page can not return unstable_notFound in "getStaticProps", please remove it to continue!`
`The /404 page can not return notFound in "getStaticProps", please remove it to continue!`
)
}

Expand Down Expand Up @@ -754,19 +754,23 @@ export async function renderToHTML(

const invalidKeys = Object.keys(data).filter(
(key) =>
key !== 'props' &&
key !== 'unstable_redirect' &&
key !== 'unstable_notFound'
key !== 'props' && key !== 'unstable_redirect' && key !== 'notFound'
)

if ((data as any).unstable_notFound) {
throw new Error(
`unstable_notFound has been renamed to notFound, please update the field to continue. Page: ${pathname}`
)
}

if (invalidKeys.length) {
throw new Error(invalidKeysMsg('getServerSideProps', invalidKeys))
}

if ('unstable_notFound' in data) {
if ('notFound' in data) {
if (pathname === '/404') {
throw new Error(
`The /404 page can not return unstable_notFound in "getStaticProps", please remove it to continue!`
`The /404 page can not return notFound in "getStaticProps", please remove it to continue!`
)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/next/types/index.d.ts
Expand Up @@ -89,7 +89,7 @@ export type GetStaticPropsResult<P> = {
props?: P
revalidate?: number | boolean
unstable_redirect?: Redirect
unstable_notFound?: true
notFound?: true
}

export type GetStaticProps<
Expand Down Expand Up @@ -140,7 +140,7 @@ export type GetServerSidePropsResult<P> =
unstable_redirect: Redirect
}
| {
unstable_notFound: true
notFound: true
}

export type GetServerSideProps<
Expand Down
Expand Up @@ -22,7 +22,7 @@ export default function Page(props) {
export const getServerSideProps = ({ query }) => {
if (query.hiding) {
return {
unstable_notFound: true,
notFound: true,
}
}

Expand Down
Expand Up @@ -22,7 +22,7 @@ export default function Page(props) {
export const getServerSideProps = ({ query }) => {
if (query.hiding) {
return {
unstable_notFound: true,
notFound: true,
}
}

Expand Down
Expand Up @@ -26,7 +26,7 @@ export default function Page(props) {
export const getStaticProps = ({ params, locale, locales }) => {
if (locale === 'en' || locale === 'nl') {
return {
unstable_notFound: true,
notFound: true,
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/integration/i18n-support/pages/not-found/index.js
Expand Up @@ -24,7 +24,7 @@ export default function Page(props) {
export const getStaticProps = ({ locale, locales }) => {
if (locale === 'en' || locale === 'nl') {
return {
unstable_notFound: true,
notFound: true,
}
}

Expand Down

0 comments on commit 75122e3

Please sign in to comment.