Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

picture tag in React

Tags:

html

reactjs

I am trying to use picture Tag in react app (jsx file) but it doesn't seems to work. Here is my code

 <picture>
      <source media="(min-width: 1024px)" src="image_Desktop.png"/>
      <source media="(max-width: 768px)" src="image_Mobile.png"/>
      <source media="(min-width: 768px) and (max-width: 1024px)" src="image_Tab.png"/>
      <img src="image.png" alt="" styleName='brain-image'/>
 </picture>

I tried giving attribute as srcset/src both in source tag but still not working.Any solution for the above problem?

like image 724
StarBoy Avatar asked May 10 '17 06:05

StarBoy


1 Answers

If you are using srcset instead of using srcSet (with capital), this could be your problem.

Here is the another problem caused by usage of srcset:

Why is React.js removing the srcset tag on <img />?

like image 166
burak Avatar answered Oct 07 '22 00:10

burak