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

What does this '.src' do here in next js?

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.

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

>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.

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