From 35e123335d249bac592920d6851f26356811b9b8 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Sat, 16 Nov 2024 00:36:31 +0100 Subject: [PATCH] add element validation and remove unused boundaries --- .../app-render/create-component-tree.tsx | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/packages/next/src/server/app-render/create-component-tree.tsx b/packages/next/src/server/app-render/create-component-tree.tsx index b6f077bea223f..8cdef1ff4a9e8 100644 --- a/packages/next/src/server/app-render/create-component-tree.tsx +++ b/packages/next/src/server/app-render/create-component-tree.tsx @@ -342,6 +342,17 @@ async function createComponentTreeInternal({ if (typeof NotFound !== 'undefined' && !isValidElementType(NotFound)) { errorMissingDefaultExport(pagePath, 'not-found') } + + if (typeof Forbidden !== 'undefined' && !isValidElementType(Forbidden)) { + errorMissingDefaultExport(pagePath, 'forbidden') + } + + if ( + typeof Unauthorized !== 'undefined' && + !isValidElementType(Unauthorized) + ) { + errorMissingDefaultExport(pagePath, 'unauthorized') + } } // Handle dynamic segment params. @@ -798,28 +809,6 @@ async function createComponentTreeInternal({ ) : undefined } - forbidden={ - Forbidden ? ( - <> - {layerAssets} - - {forbiddenStyles} - - - - ) : undefined - } - unauthorized={ - Unauthorized ? ( - <> - {layerAssets} - - {unauthorizedStyles} - - - - ) : undefined - } > {layerAssets} {serverSegment}