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

238
Vistas
How can we import the image from one js file to another js file

I am trying to import the image from one js file to another js file. My first js file is as function component Track.js

import React from 'react'
import { screenimage, screenimage1 } from "./srcimages.js";

function Track() {
    return (
        <div>
            Hello Component
            <img src={screenimage} alt=""/>
            <img src={screenimage1} alt=""/>
        </div>
    )
}

export default Track

My second js file is as const image.js

const screenimage = 'https://image.shutterstock.com/image-illustration/shopping-online-concept-modern-design-260nw-1934432345.jpg';
const screenimage1 = 'https://www.publicdomainpictures.net/pictures/320000/velka/background-image.png';

I am trying to make a collection of multiple image source in one js file and import it as img <img src={here}/> attribute. I tried the above method but it's showing empty value of src.

UPDATE Remove the tag "typoscript" from this post

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

0

You need to export the images from the image.js file. Check the code below:

export const screenimage = "https://image.shutterstock.com/image-illustration/shopping-online-concept-modern-design-260nw-1934432345.jpg";
export const screenimage1 = "https://www.publicdomainpictures.net/pictures/320000/velka/background-image.png";
about 4 years ago · Juan Pablo Isaza Denunciar

0

So try add the export behind the const

like

export const screenimage = 'https://image.shutterstock.com/image-illustration/shopping-online-concept-modern-design-260nw-1934432345.jpg',

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