on-internet
← Community

React's mouseEvent doesn't have offsetX/offsetY

Stack Overflow ·

I try get position of click relative to element, but event doesn't have offsetX. onClick(e) { console.log(e.offsetX) // returns undefined console.log(e.target.offsetX) // returns undefined } render() { return <img src='http://placehold.it/1000x500' onClick={this.onClick} /> } How I can get position of click in element?

Comments

Sign in or sign up to comment and upvote.

No comments yet.