Promise approach :
Syntax for dynamic imports :
import("path").then(module=>{
//module.default
})
Module :
the module has a bunch of properties like data etc.
module.default for default export
module. something for named export.
async and await :
syntax : const variable = ( await import("../names")).default
Controlling chunk name :
syntax : /* chunk name */
example :
const names=( await import("../names" /* chunk names */)).default
lazy(load): Call lazy outside your components to declare a lazy-loaded React component:
syntax :
const name = lazy(() => import('./file//path.js')); for default export
const name = lazy(() => import('./file//path.js')).then(module=>{return {module : module.componentName}})
example :