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
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";
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',