Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

241
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!