Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

151
Vistas
React Lazy and Suspense issue

i have create e simple test app with CRA for testing Lazy / Suspense features in react 18, but I'am stuck, this is my code:

// App.js

import React from "react";

const Test = React.lazy(() => {
  import("./components/Test");
});

function App() {
  return (
    <div className="App">
      <Test />
    </div>
  );
}

export default App;


and this is my Test.js code:

import React from "react";

const Test = () => {
  return <div>test</div>;
};

export default Test;

very simple, but when I run npm start this is my console error:

react.development.js:1361 Uncaught TypeError: Cannot read properties of undefined (reading 'then')
    at lazyInitializer (react.development.js:1361:1)
    at mountLazyComponent (react-dom.development.js:20763:1)
    at beginWork (react-dom.development.js:22422:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:4161:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4210:1)
    at invokeGuardedCallback (react-dom.development.js:4274:1)
    at beginWork$1 (react-dom.development.js:27405:1)
    at performUnitOfWork (react-dom.development.js:26513:1)
    at workLoopSync (react-dom.development.js:26422:1)
    at renderRootSync (react-dom.development.js:26390:1)

I can't understand where I'm wrong. Any ideas? thx all!

7 months ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos