How to get mouse coordinates in React and jQuery?

Posted by Jessica Taylor | Updated on

Want to get mouse coordinates in React and jQuery? As others have mentioned, the issue is that react has not rendered your component to the DOM when jQuery tries to attach the event listener.

You don’t need jQuery to do this at all, a better approach is to use the React events:

Here is a working example.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers