-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
The dynamic imports
modules function no longer receive props in next7
#5208
Comments
This is expected, as a breaking change of #4639.
|
The way to go about doing this is: import dynamic from 'next/dynamic'
const Facebook = dynamic({
loader: () => import('./icons/Facebook')
})
const Twitter = dynamic({
loader: () => import('./icons/Twitter')
})
const Github = dynamic({
loader: () => import('./icons/Github')
})
const Awesome = dynamic({
loader: () => import('./icons/Awesome')
})
export default function DynamicBundle({name, ...props}) {
switch(name) {
case 'facebook': {
return <Facebook {...props} />
}
case 'twitter': {
return <Twitter {...props} />
}
case 'github': {
return <GitHub {...props} />
}
}
return <Awesome {...props} />
} |
The way it worked in next6 with the way I did it was it only loaded the components that was being used. I tried your example @timneutkens but when I view the network panel in chrome I see it loading all the components(chunks), not just the once I'm using. (Tried it with dev and build) |
Example here: https://github.com/ProfChaos/nexttest Network pane |
Bug report
Describe the bug
With Next6 the modules function for dynamic imports received props, but in Next7 it does not receive any props.
To Reproduce
Gives this error
Unhandled Rejection (TypeError): Cannot read property 'name' of undefined
Expected behavior
Since the the blog post said dynamic imports are fully backwards-compatible, I expect to receive props in the modules function.
System information
The text was updated successfully, but these errors were encountered: