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

260
Vistas
Critical dependency: the request of a dependency is an expression while using lazy loading

I am trying to dynamically import modules but getting following error -

Compiled with problems:X

WARNING in ./src/.../useCustomModule.js 21:21-56

Critical dependency: the request of a dependency is an expression

import React from "react";
import PropTypes from "prop-types";

export const moduleMapping = {
    CONTEXT_ONE: "./....contextOnePath",
    CONTEXT_TWO: "./....contextTwoPath",
    
};

const getModule = (moduleName) => {
    const module = React.lazy(() => import(moduleMapping[moduleName]));
    return module;
};

export const useCustomModule = (moduleName) => {
    return getModule(moduleName);
};

Note : In eslintrc.json I have following settings - "ecmaVersion": 12,

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Recently, I also faced a similar issue but when I used string interpolation, the warning went away. In your code, give a try to this:

const getModule = (moduleName) => {
    const module = React.lazy(() => import(`${moduleMapping[moduleName])}`);
    return module;
};
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