Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outlet in root route prevents suspense from bubbling up #2026

Open
lukasgeiter opened this issue Jul 25, 2024 · 4 comments
Open

Outlet in root route prevents suspense from bubbling up #2026

lukasgeiter opened this issue Jul 25, 2024 · 4 comments

Comments

@lukasgeiter
Copy link

Describe the bug

I would like to use my own loading component at the root level. To do that I'm wrapping the <Outlet> in the root component with a <Suspense> block. Unfortunately, Outlet wraps the children in a <Suspense> block of its own, preventing mine from being used. Since I have no defaultPendingComponent configured, it renders nothing.

I have traced the issue to this part of the code:

const pendingElement = router.options.defaultPendingComponent ? (
<router.options.defaultPendingComponent />
) : null
if (matchId === rootRouteId) {
return (
<React.Suspense fallback={pendingElement}>{nextMatch}</React.Suspense>
)
}

Your Example Website or App

https://stackblitz.com/edit/github-s38jue?file=src%2Froutes%2F__root.tsx

Steps to Reproduce the Bug or Issue

  1. Run the Stackblitz

Expected behavior

As a user, I expect to see the fallback content Suspense fallback - I expect this to show up, but I'm seeing nothing (besides the navigation)

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Arc (Chrome)
  • Version: 1.52.0 (51895)

Additional context

Related issue: #1049

@schiller-manuel
Copy link
Contributor

does #2035 solve your issue?

@lukasgeiter
Copy link
Author

@schiller-manuel that would certainly be an improvement 👍

Although, I'm still of the opinion that if no pending components are configured, the router shouldn't wrap anything in a suspense at all. I don't think rendering a suspense with null as fallback is a good default.

@schiller-manuel
Copy link
Contributor

like this? 3518ac3

I am not sure which implications this has, so I need reviews.

@lukasgeiter
Copy link
Author

Yeah, that's what I had in mind. Not sure if the failing tests mean that this is a bad idea, or if they should be adjusted 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants