@@ -367,31 +367,45 @@ export const Outlet = () => {
367367 } ,
368368 } )
369369
370+ const childMatchStatus = useRouterState ( {
371+ select : ( s ) => {
372+ const matches = s . matches
373+ const index = matches . findIndex ( ( d ) => d . id === matchId ( ) )
374+ return matches [ index + 1 ] ?. status
375+ } ,
376+ } )
377+
378+ // Only show not-found if we're not in a redirected state
379+ const shouldShowNotFound = ( ) =>
380+ childMatchStatus ( ) !== 'redirected' && parentGlobalNotFound ( )
381+
370382 return (
371- < >
372- < Solid . Show when = { parentGlobalNotFound ( ) } >
373- { renderRouteNotFound ( router , route ( ) , undefined ) }
374- </ Solid . Show >
375- < Solid . Show when = { childMatchId ( ) } >
376- { ( matchId ) => {
377- // const nextMatch = <Match matchId={matchId()} />
378-
379- return (
380- < Solid . Show
381- when = { matchId ( ) === rootRouteId }
382- fallback = { < Match matchId = { matchId ( ) } /> }
383+ < Solid . Show
384+ when = { ! shouldShowNotFound ( ) && childMatchId ( ) }
385+ fallback = {
386+ < Solid . Show when = { shouldShowNotFound ( ) } >
387+ { renderRouteNotFound ( router , route ( ) , undefined ) }
388+ </ Solid . Show >
389+ }
390+ >
391+ { ( matchId ) => {
392+ // const nextMatch = <Match matchId={matchId()} />
393+
394+ return (
395+ < Solid . Show
396+ when = { matchId ( ) === rootRouteId }
397+ fallback = { < Match matchId = { matchId ( ) } /> }
398+ >
399+ < Solid . Suspense
400+ fallback = {
401+ < Dynamic component = { router . options . defaultPendingComponent } />
402+ }
383403 >
384- < Solid . Suspense
385- fallback = {
386- < Dynamic component = { router . options . defaultPendingComponent } />
387- }
388- >
389- < Match matchId = { matchId ( ) } />
390- </ Solid . Suspense >
391- </ Solid . Show >
392- )
393- } }
394- </ Solid . Show >
395- </ >
404+ < Match matchId = { matchId ( ) } />
405+ </ Solid . Suspense >
406+ </ Solid . Show >
407+ )
408+ } }
409+ </ Solid . Show >
396410 )
397411}
0 commit comments