React Lazy Load not working with variable path

This issue has been created 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.

https://stackoverflow.com/questions/tagged/react

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.

https://reactjs.org/community/support.html

More Details About Repo
Owner Name facebook
Repo Name react
Full Name facebook/react
Language JavaScript
Created Date 2013-05-24
Updated Date 2022-09-26
Star Count 195293
Watcher Count 6655
Fork Count 40426
Issue Count 1113

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
ugettext_lazy is deprecated causing warnings 2 2020-07-09 2022-09-18
RmInitAdapter failed! 6 2022-05-19 2022-09-25
Update vehicle inventory identifier when plate changes 5 2022-04-25 2022-09-10
New position value "bucket" 1 2022-05-06 2022-08-29
Reserve device ID 41 for GPIO device 1 2021-06-02 2022-09-22
i2c: Allow buffer less transactions 6 2021-07-27 2022-09-10
snd: extend virtio sound device with audio controls 1 2021-04-22 2022-09-10
block: make lifetime metrics feature independent of the eMMC standard 1 2021-04-20 2022-09-10
[Bug] update check never sees a new version 4 2021-07-13 2022-09-10
share local caches under different repo 1 2022-02-16 2022-09-18
Expected a color when using CSS variables 3 2018-08-13 2022-09-03
ERROR AL UTILIZAR SNIPPETS CSS.JSON 0 2021-09-01 2022-09-08
Printing a RunningCommand Seems to Rerun It 1 2021-03-25 2022-09-26
Support multiple tags in module community.vmware.vmware_vm_storage_policy 2 2021-11-17 2022-08-28
USB device not recognised 6 2019-08-23 2022-08-28
Recoverer module is throwing timeout 0 2021-06-01 2022-09-17
eLife Theme: no space between the `name` of an `Organization` and the `name` of it's `parentOrganization` 1 2020-10-22 2022-09-24
How to use array values as keys for validation? 2 2022-08-01 2022-08-11
Can't write track_message to server 16 2015-08-19 2022-09-17
2.4: Dialog card column could stand to be bigger when window size > 1024 4 2021-12-16 2022-09-04
Issues importing EDL and XML files from Davinci Resolve 4 2021-08-15 2022-09-19
allow `coord_fixed()` with `facet_grid(..., scales = "free", space = "free")` when x and y scales are discrete 5 2021-08-12 2022-09-26
Shortcut inconsistency 2 2021-08-03 2022-09-26
{{=#this}} 这里的 等号是啥意思呢。 0 2022-08-10 2022-09-10
word文档导入对于特殊字符★等展示不正确 0 2022-08-19 2022-09-10
区块如何翻页,我导出的时候自动连在一页了 0 2022-08-17 2022-09-10
如何对表格文字设置自动换行、文字大小自适应? 3 2022-08-13 2022-09-10
latest release tagged 1.17.1-1 but is actually 1.17.0-1 so causes endless update loop 1 2021-06-04 2022-09-06
Default configuration makes dashboard unusable 0 2022-09-12 2022-09-25
Who to contact for security issues 5 2022-01-15 2022-09-08
Add text2text (generation) transformer module 2 2022-02-24 2022-09-08
Service is not installing after compiling 17 2020-01-07 2022-09-17
PDF - 'ImageMalformed: NoEnabledDecoderFound 1 2022-02-16 2022-09-04
error running command "istioctl version" 1 2021-12-07 2022-07-25
The documentation is no longer avaliable 3 2022-06-28 2022-09-18
Add option to use hashes of resolved modules 1 2021-09-28 2022-08-09
kubectl --dry-run=true is deprecated 0 2020-05-06 2022-08-26
Issue ID: DAC_Non_Descriptive_Links3 0 2022-05-27 2022-09-16
Investigate TODO in OpenVPN analyzer 0 2021-03-22 2022-08-08
Support model graphs with circular dependencies 0 2022-07-28 2022-09-14
The Cypress App could not be installed after setting up HTTP_PROXY 1 2022-03-21 2022-08-21
Cypress is reporting no specs found, but the spec definitely exists 9 2022-03-22 2022-07-23
[Multi-domain]: Support cy.intercept() in the multi-domain command callback 1 2022-03-21 2022-07-21
ZHA: Boek TRV TGR85-ZB not working 2 2022-08-28 2022-08-23
Opening Interactive window breaks editor "sticky scrolling" functionality 6 2022-08-05 2022-09-17
Bad format when a link has very long text in vue file 2 2022-03-29 2022-09-23
cropped stroke line with gradient fill with partial opacity 6 2021-05-27 2022-09-15
[Bug]: sp-slider doesn't allow touch-dragging 2 2022-01-07 2022-08-27
Define a maximum aspect ratio 0 2021-09-16 2022-09-20
Warning about a "invalid file link" but when build the link just works 1 2021-11-22 2022-09-16