Next.js Discord

Discord Forum

Template literals in dynamic import

Unanswered
Danish-Swedish Farmdog posted this in #help-forum
Open in Discord
Danish-Swedish FarmdogOP
Hey there ,

I am trying to use dynamic imports to loop over a json config to provide me with components . Docs says it is not possible but this github link does https://github.com/vercel/next.js/issues/4100

Could someone clarify why would i get undefined across the board ?

   {config.map((section, index) => {
     const Component = dynamic(() =>                                         import(`./sections/${section.component}`).then(module => module[section.component]))
      return (
          <Component
              key={index}
            />
        )
    })}

0 Replies