From 75122e32cca53dc3d4f84198fb8d87747c0fb59d Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 27 Oct 2020 01:00:02 -0500 Subject: [PATCH 1/2] Remove unstable_ prefix from unstable_notFound --- packages/next/next-server/server/render.tsx | 20 +++++++++++-------- packages/next/types/index.d.ts | 4 ++-- .../pages/not-found/[slug].js | 2 +- .../pages/not-found/index.js | 2 +- .../pages/not-found/fallback/[slug].js | 2 +- .../i18n-support/pages/not-found/index.js | 2 +- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/next/next-server/server/render.tsx b/packages/next/next-server/server/render.tsx index 7aa8cf64faafd..1bbd4c5abc853 100644 --- a/packages/next/next-server/server/render.tsx +++ b/packages/next/next-server/server/render.tsx @@ -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')) { @@ -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!` ) } @@ -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!` ) } diff --git a/packages/next/types/index.d.ts b/packages/next/types/index.d.ts index f834d3114fa0e..23c5e662ed7a4 100644 --- a/packages/next/types/index.d.ts +++ b/packages/next/types/index.d.ts @@ -89,7 +89,7 @@ export type GetStaticPropsResult

= { props?: P revalidate?: number | boolean unstable_redirect?: Redirect - unstable_notFound?: true + notFound?: true } export type GetStaticProps< @@ -140,7 +140,7 @@ export type GetServerSidePropsResult

= unstable_redirect: Redirect } | { - unstable_notFound: true + notFound: true } export type GetServerSideProps< diff --git a/test/integration/getserversideprops/pages/not-found/[slug].js b/test/integration/getserversideprops/pages/not-found/[slug].js index 158be98be1cef..a2b94c1582bca 100644 --- a/test/integration/getserversideprops/pages/not-found/[slug].js +++ b/test/integration/getserversideprops/pages/not-found/[slug].js @@ -22,7 +22,7 @@ export default function Page(props) { export const getServerSideProps = ({ query }) => { if (query.hiding) { return { - unstable_notFound: true, + notFound: true, } } diff --git a/test/integration/getserversideprops/pages/not-found/index.js b/test/integration/getserversideprops/pages/not-found/index.js index 158be98be1cef..a2b94c1582bca 100644 --- a/test/integration/getserversideprops/pages/not-found/index.js +++ b/test/integration/getserversideprops/pages/not-found/index.js @@ -22,7 +22,7 @@ export default function Page(props) { export const getServerSideProps = ({ query }) => { if (query.hiding) { return { - unstable_notFound: true, + notFound: true, } } diff --git a/test/integration/i18n-support/pages/not-found/fallback/[slug].js b/test/integration/i18n-support/pages/not-found/fallback/[slug].js index e4e809bc4f321..0fde7256d1aae 100644 --- a/test/integration/i18n-support/pages/not-found/fallback/[slug].js +++ b/test/integration/i18n-support/pages/not-found/fallback/[slug].js @@ -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, } } diff --git a/test/integration/i18n-support/pages/not-found/index.js b/test/integration/i18n-support/pages/not-found/index.js index 18a9bd7996f83..b6652953a9af6 100644 --- a/test/integration/i18n-support/pages/not-found/index.js +++ b/test/integration/i18n-support/pages/not-found/index.js @@ -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, } } From fade5d4939d444beba31baf1df31e60cea403c22 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Tue, 27 Oct 2020 04:42:10 -0400 Subject: [PATCH 2/2] fix bug --- packages/next/next-server/server/render.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/next/next-server/server/render.tsx b/packages/next/next-server/server/render.tsx index e19e76f39fe22..85d2423fbc3ce 100644 --- a/packages/next/next-server/server/render.tsx +++ b/packages/next/next-server/server/render.tsx @@ -759,8 +759,7 @@ export async function renderToHTML( } const invalidKeys = Object.keys(data).filter( - (key) => - key !== 'props' && key !== 'unstable_redirect' && key !== 'notFound' + (key) => key !== 'props' && key !== 'redirect' && key !== 'notFound' ) if ((data as any).unstable_notFound) {