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

Fallback for nested lazy loading? #4

Open
tal-rofe opened this issue Feb 24, 2023 · 2 comments
Open

Fallback for nested lazy loading? #4

tal-rofe opened this issue Feb 24, 2023 · 2 comments

Comments

@tal-rofe
Copy link

The usage in this repository is good for root level routes only.
If there are some nested routes (which are also lazy loaded..),
then the fallback value for React.Suspense will be only the nested lazy loaded "page", and that will make a bad UI for the fallback.

Assume you have a lazy loaded component X with some navbar element. Then, you configure in this component X an <Outlet />. Then, if the future-injected <Outlet> element will be lazy loaded as well, the root <React.Suspense> will be loaded with partial fallback element, as the fallback element will be the content of the <Outlet>, but the real "page" includes also the navbar, which won't be shown in the fallback state.

Is there a way to overcome it?

@trandinhhiep789
Copy link

trandinhhiep789 commented Nov 30, 2023

The usage in this repository is good for root level routes only. If there are some nested routes (which are also lazy loaded..), then the fallback value for React.Suspense will be only the nested lazy loaded "page", and that will make a bad UI for the fallback.

Assume you have a lazy loaded component X with some navbar element. Then, you configure in this component X an <Outlet />. Then, if the future-injected <Outlet> element will be lazy loaded as well, the root <React.Suspense> will be loaded with partial fallback element, as the fallback element will be the content of the <Outlet>, but the real "page" includes also the navbar, which won't be shown in the fallback state.

Is there a way to overcome i

Hi tal-rofe, Have you solved this problem yet?

@tal-rofe
Copy link
Author

tal-rofe commented Nov 30, 2023

@trandinhhiep789 Yes I have an open source project where I solved it. You can see it in Exlint/dashboard repository in my profile: https://github.com/Exlint/dashboard/blob/main/apps/frontend/src/App.router.tsx

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