Skip to content

Commit 75122e3

Browse files
committed
Remove unstable_ prefix from unstable_notFound
1 parent 4782bda commit 75122e3

File tree

6 files changed

+18
-14
lines changed

6 files changed

+18
-14
lines changed

packages/next/next-server/server/render.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ export async function renderToHTML(
625625
key !== 'revalidate' &&
626626
key !== 'props' &&
627627
key !== 'unstable_redirect' &&
628-
key !== 'unstable_notFound'
628+
key !== 'notFound'
629629
)
630630

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

639-
if (data.unstable_notFound) {
639+
if (data.notFound) {
640640
if (pathname === '/404') {
641641
throw new Error(
642-
`The /404 page can not return unstable_notFound in "getStaticProps", please remove it to continue!`
642+
`The /404 page can not return notFound in "getStaticProps", please remove it to continue!`
643643
)
644644
}
645645

@@ -754,19 +754,23 @@ export async function renderToHTML(
754754

755755
const invalidKeys = Object.keys(data).filter(
756756
(key) =>
757-
key !== 'props' &&
758-
key !== 'unstable_redirect' &&
759-
key !== 'unstable_notFound'
757+
key !== 'props' && key !== 'unstable_redirect' && key !== 'notFound'
760758
)
761759

760+
if ((data as any).unstable_notFound) {
761+
throw new Error(
762+
`unstable_notFound has been renamed to notFound, please update the field to continue. Page: ${pathname}`
763+
)
764+
}
765+
762766
if (invalidKeys.length) {
763767
throw new Error(invalidKeysMsg('getServerSideProps', invalidKeys))
764768
}
765769

766-
if ('unstable_notFound' in data) {
770+
if ('notFound' in data) {
767771
if (pathname === '/404') {
768772
throw new Error(
769-
`The /404 page can not return unstable_notFound in "getStaticProps", please remove it to continue!`
773+
`The /404 page can not return notFound in "getStaticProps", please remove it to continue!`
770774
)
771775
}
772776

packages/next/types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export type GetStaticPropsResult<P> = {
8989
props?: P
9090
revalidate?: number | boolean
9191
unstable_redirect?: Redirect
92-
unstable_notFound?: true
92+
notFound?: true
9393
}
9494

9595
export type GetStaticProps<
@@ -140,7 +140,7 @@ export type GetServerSidePropsResult<P> =
140140
unstable_redirect: Redirect
141141
}
142142
| {
143-
unstable_notFound: true
143+
notFound: true
144144
}
145145

146146
export type GetServerSideProps<

test/integration/getserversideprops/pages/not-found/[slug].js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function Page(props) {
2222
export const getServerSideProps = ({ query }) => {
2323
if (query.hiding) {
2424
return {
25-
unstable_notFound: true,
25+
notFound: true,
2626
}
2727
}
2828

test/integration/getserversideprops/pages/not-found/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function Page(props) {
2222
export const getServerSideProps = ({ query }) => {
2323
if (query.hiding) {
2424
return {
25-
unstable_notFound: true,
25+
notFound: true,
2626
}
2727
}
2828

test/integration/i18n-support/pages/not-found/fallback/[slug].js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function Page(props) {
2626
export const getStaticProps = ({ params, locale, locales }) => {
2727
if (locale === 'en' || locale === 'nl') {
2828
return {
29-
unstable_notFound: true,
29+
notFound: true,
3030
}
3131
}
3232

test/integration/i18n-support/pages/not-found/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function Page(props) {
2424
export const getStaticProps = ({ locale, locales }) => {
2525
if (locale === 'en' || locale === 'nl') {
2626
return {
27-
unstable_notFound: true,
27+
notFound: true,
2828
}
2929
}
3030

0 commit comments

Comments
 (0)