Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I can't use images from local files in react

ProfilePage.js


import React from 'react'

export default function ProfilePage() {
    return (
        <div>
            <div className='bg-slate-500 rounded-3xl text-center items-center'>
                
                <img className='w-full h-16' src='/src/images/backgroundImage.jpg' alt='couldnt find' />
            </div>
            
        </div>
    )
}

I’m getting a 401 unauthorized error.

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How can i use images in react ?

>Solution :

In order to load local images to your React.js application, you need to add import your file.

import backgroud_image from "/src/images/backgroundImage.jpg";
<img className='w-full h-16' src={backgroud_image } alt='couldnt find' />
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading