Here I’m setting background image in Next js. I’ve found a solution here to add .src at the end like this
import bgImg from '../public/images/Error/BG.png';
<Layout style={{ backgroundImage: `url(${bgImg.src})`}}> </Layout>
I don’t know what the src in bgImg.src do?.
Please explain.
>Solution :
If you console.log(bgImg)
You will find the output syntax to be like:
bgImg: {
src: '...',
height: 1028,
width: 1013,
blurDataURL: '...'
}
So your are basically accessing image source object value with dot notation.