React Lazy Load not working with variable path

This issue has been tracked since 2022-09-19.

I have the same issue when using Lazy Load with variable path.

if I put the path in the variable, I see "Can't find the module"

const filePath = `@pages/general/general`;
const component = React.lazy(() => import(`${filePath}`));

but if I put the path directly, it's working

  const component = React.lazy(() => import("@pages/general/general"));

any suggestions?

_Originally posted by #16132 (comment)

eps1lon wrote this answer on 2022-09-19

Dynamic import with a variable requires using bundlers (e.g. Webpack) that support this syntax.

Support requests filed as GitHub issues often go unanswered. We want you to find the answer you're looking for, so we suggest the following alternatives:

Coding Questions
If you have a coding question related to React and React DOM, it might be better suited for Stack Overflow. It's a great place to browse through frequent questions about using React, as well as ask for help with specific questions.

Talk to other React developers
There are many online forums which are a great place for discussion about best practices and application architecture as well as the future of React.

More Details About Repo
Owner Name facebook
Repo Name react
Full Name facebook/react
Language JavaScript
Created Date 2013-05-24
Updated Date 2022-10-03
Star Count 195560
Watcher Count 6648
Fork Count 40508
Issue Count 1111


Issue Title Created Date Updated Date