diff --git a/contributors.yml b/contributors.yml index 0966b71f78..930896497b 100644 --- a/contributors.yml +++ b/contributors.yml @@ -470,6 +470,7 @@ - yuleicul - yuri-poliantsev - zeevick10 +- scott-memco - zeromask1337 - zheng-chuang - zxTomw diff --git a/packages/react-router/lib/router/router.ts b/packages/react-router/lib/router/router.ts index 34c74cc28d..ebf470b87d 100644 --- a/packages/react-router/lib/router/router.ts +++ b/packages/react-router/lib/router/router.ts @@ -5378,10 +5378,16 @@ function isSameRoute( return true; } + // If only one side has children, they're different routes (e.g., sibling + // layouts where one has been patched with children and the other hasn't) + if (!newRoute.children?.length || !existingRoute.children?.length) { + return false; + } + // Otherwise, we look to see if every child in the new route is already // represented in the existing route's children - return newRoute.children!.every((aChild, i) => - existingRoute.children?.some((bChild) => isSameRoute(aChild, bChild)), + return newRoute.children.every((aChild) => + existingRoute.children!.some((bChild) => isSameRoute(aChild, bChild)), ); }