-1

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

How can i use images in react ?

1 Answers1

1

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' />
Ajay Gupta
  • 703
  • 5
  • 11