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

224
Vistas
How to import images url inside a javascript file

So I copied a code in react to native javascript. I have a folder named imgs this folder contains all the images and an index.js file that looks like this.

export { default as img1 } from "./one.jpg";
export { default as img2 } from "./two.jpg";
export { default as img3 } from "./three.jpg";
export { default as img4 } from "./four.jpg";
export { default as img5 } from "./five.jpg";

Now I tried to import these images to another file like this

import { img1, img2, img3, img4, img5 } from "./imgs";

and I get an error in my console enter image description here

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

this works like a charm when I used it in CRA but it doesn't work here. What am I missing

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

0

In my projects, I create a file and put all the image calls in it

const image1=requre("../location image ")

export {
image1
}

And in the file where I want to use the pictures

import {image1} from  "../images file"

<Image source={image1} />
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