-
Notifications
You must be signed in to change notification settings - Fork 41
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
feat: add support for client only lazy loading with dynamic
#331
Conversation
3bb62cb
to
ac82a8a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few additional considerations:
-
It would be useful to add some unit tests about this component for both client and ssr case (we should be able to mock window via
vitest
). -
About
release the dynamic with the console error (which is fine since it is not blocking for the users)
We should add the documentation about
dynamic()
usage alongside a warning about the expected error (informing that it will be fixed in the next release) -
Maybe this could be also added to the tutorial but I think is better to do it after we fixed the ssr error
184c7a0
to
727d870
Compare
Context & Description
Closes: #258
This PR extends the usage of the
dynamic
function, making its usage the same as Next.jsQuick takeaways:
tuono-lazy-fn-vite-plugin
gets completely droppeddynamic
takes an obj as second argument{ ssr: boolean, loading: JSX.Element }
Good to know:

using
ssr: true
we get the following console errorThis is expected because what is rendered on the server doesn't match the client.
After investigating how Next.js fixed this issue, I found that they have an error boundary that enhances and filters the console errors triggered by React. Basically, every
dynamic
hydration error gets labeled bynext/dynamic
so they automatically remove it at runtime!I'd propose to address the
ErrorBoundary
after this and release the dynamic with the console error (which is fine since it is not blocking for the users)