-
Notifications
You must be signed in to change notification settings - Fork 27k
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
update client-only-render-external-dependency example #4822
update client-only-render-external-dependency example #4822
Conversation
import dynamic from 'next/dynamic' | ||
|
||
export default dynamic({ | ||
modules: props => ({ |
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.
Lets remove props
this is going to be removed in Next 7
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.
sure. Btw I was not sure how to best approach this example.
I tried to just make dynamic imports directly in pages like:
const BarChart = dynamic(import('recharts').then(({ BarChart }) => BarChart), { ssr: false }),
const Bar = dynamic(import('recharts').then(({ Bar }) => Bar), { ssr: false })
But I experienced charts not being drawn. I think that these two components had to be together ready before they were rendered. The above way solved the issue.
I also thought about just making a directory BarChart and LineChart with index.js
file exporting:
export default dynamic(import('./BarChart'), { ssr: false });
// ... and
export default dynamic(import('./LineChart'), { ssr: false });
but this would resolve in recharts
being bundled twice for these two chunks (and it's quite big).
import dynamic from 'next/dynamic' | ||
|
||
export default dynamic({ | ||
modules: props => ({ |
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.
Same here as my other comment
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.
Should be fine like this 👍
How can use |
Changes:
dynamic
imports instead ofrequire
recharts
dependency