Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda