Why is React.js removing the srcset tag on <img />?
Another ugly solution using template literals:
<img
alt=''
src={require('../../assets/images/logo/logo.png')}
srcSet={`
${require('../../assets/images/logo/[email protected]')} 2x,
${require('../../assets/images/logo/[email protected]')} 3x
`}
/>
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