Skip to content

The dynamic imports modules function no longer receive props in next7 #5208

@ProfChaos

Description

@ProfChaos

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

import dynamic from 'next/dynamic'
const DynamicBundle = dynamic({
  modules: ({ name }) => {
    const comp = {}
    switch (name) {
      case 'facebook':
        comp.Danamic = import('./icons/Facebook')
        break
      case 'twitter':
        comp.Danamic = import('./icons/Twitter')
        break
      case 'github':
        comp.Danamic = import('./icons/Github')
        break
      default:
        comp.Danamic = import('./icons/Awesome')
        break
    }
    return comp
  },
  render: (props, { Danamic }) => {
    return (
       <Danamic {...props} />
    )
  }
})

export default DynamicBundle

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

  • OS: macOs
  • Version of Next.js: 7.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions