i creating img tag want listen onload event for, need actual image object can check width/height, etc on it. these created dynamically, can't know id beforehand.
//in jsx: <img src={this.generatesrc(config)} onload={this.handleonload} /> in normal javascript, do:
<img onload="somefunction(this)" /> how pass in reactjs?
you actual image object via e.target.
handleonload(e) { console.log(e.target); } or via refs component
handleonload() { console.log(this.refs.img); } <img ref='img' src={this.generatesrc(config)} onload={this.handleonload.bind(this)} />
Comments
Post a Comment