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

Kevin Ghadyani picture Kevin Ghadyani · Jan 9, 2016 · Viewed 19.4k times · Source

When I have the srcset property on my <img /> tag, why doesn't it show up in the browser? It appears as through React.js is stripping it out.

<img src="/images/logo.png" srcset="/images/logo-1.5x.png 1.5x, /images/logo-2x.png 2x" />

Answer

Kevin Ghadyani picture Kevin Ghadyani · Jan 9, 2016

The solution is to use srcSet instead of srcset.

<img src="/images/logo.png" srcSet="/images/logo-1.5x.png 1.5x, /images/logo-2x.png 2x" />

Reference: https://facebook.github.io/react/docs/tags-and-attributes.html under HTML Attributes