Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
Cannot use "react.lazy" in webpack

I'm having a problem using react.lazy in my webpack 4 project ("webpack": "^4.16.1")

this is my code for this problem:

import React, { Suspense, lazy } from "react";
const AccountInfo = lazy(() => import("../../views/Account")) ;

...

<Suspense fallback={<div>Loading...</div>}>
   <Switch>
     <PrivateRoute path="/accountinfo" component={AccountInfo} >
   <Switch/>
</Suspense >

this is file .babelrc

{
  "plugins": [
    [
      "transform-class-properties",
      {
        "spec": true
      }
    ]
  ]
}

and the error message is: enter image description here

can someone help me? Have a nice day guys <3

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think, you need to add the @babel/plugin-syntax-dynamic-import plugin (https://babeljs.io/docs/en/babel-plugin-syntax-dynamic-import) and modify your .babelrc file. Then it should be able to do the dynamic imports.

{
    "presets": [
      "@babel/preset-react"
    ],
    "plugins": [
      "@babel/plugin-syntax-dynamic-import"
    ]
}

You are also using an old version of webpack (version 4). Can you upgrade to a current version of webpack (5) (https://www.npmjs.com/package/webpack)?

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!