Search code examples
reactjsimagehttpsjpeg

React https image link working but local image link isn’t


I have an images.js file in React that imports data.

import { aData } from './aData';

I have a data.js file with the following code.

export const aData = [
  {
    image:
      'https://…'
  },
  {
    image:
      '.\images1\a.jpg'
  }
];

The jpg is in a folder inside the same folder as the images.js and aData.js files but while the https file displays, the jpg does not. These are the paths:

src\components\images1\a.jpg
src\components\images.js
src\components\aData.js

Solution

  • try changing the slash { image: './components/images1/a.jpg' }