I have a React Server Side processed side with a tag img. I want to add an event listener onloadto the image tag and make the component as shown below:
render () {
return (
<img onLoad={() => { console.log('Image loaded'); }} src='/abc.jpg'/>
)
}
Ideally, a React renderToStringmethod should generate an HTML template, as shown below:
<img onload='function () { console.log('Image loaded'); }' src='/abc.jpg' />
but this is not so. What am I missing? I checked there was a similar problem here , but without a solution
source
share