Skip to content

Can dynamic() imports fallback to a <Suspense/> boundary up the tree still? Or only using the new loading() parameter #44412

Answered by icyJoseph
mcgrealife asked this question in Help
Discussion options

You must be logged in to vote

I am not sure what you mean. next/dynamic is a sort of enhanced version of React.lazy. And both are facades or wrappers, for import(). It's not always the case that one would want to lazily/dynamically, load a component, but also a library.

React.lazy's behaviour is to suspend, and it requires a Suspense wrapper. next/dynamic went ahead and tried to implement all of the above, library loading, lazy client bundle, with or without SSR, a custom loading placeholder, etc. The package itself has evolved quite a bit, but there's a few gotchas with React 18.

In React 18 Server Components, the loading is awaited, so it might not be behaving at all as you expect it.

If we follow the docs:

There a…

Replies: 1 suggested answer 1 reply

Comment options

You must be logged in to vote
1 reply
@mcgrealife
Comment options

Answer selected by mcgrealife
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants