Accepted answer

Only partially dynamic statement are allowed for import().

In your AppRoutes.js you could do this:

    getComponent={() => import('pages/default/HomePage')}

then in your LazyLoad Component you do:

componentDidMount() {
    .then(module => module.default)
    .then(AsyncModule => this.setState({AsyncModule}))

Fully dynamic statements, such as import(foo), will fail because webpack requires at least some file location information.The import() must contain at least some information about where the module is located, so bundling can be limited to a specific directory or set of files.

Related Query

More Query from same tag