Skip to content

React hook for getting MouseEvent pageX and pageY values

License

Notifications You must be signed in to change notification settings

rawrmonstar/window-mouse-position

 
 

Repository files navigation

@rehooks/window-mouse-position

React hook for mouse position on window

Note: This is using the new React Hooks API Proposal which is subject to change until React 16.7 final.

You'll need to install react, react-dom, etc at ^16.7.0-alpha.0

Install

yarn add @rehooks/window-mouse-position

Usage

import useWindowMousePosition from "@rehooks/window-mouse-position";

function MyComponent() {
  let { x, y } = useWindowMousePosition();
  return (
    <div style={{ width: "100%", height: "100%" }}>
      <pre>{JSON.stringify({ x, y })}</pre>
    </div>
  );
}

About

React hook for getting MouseEvent pageX and pageY values

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 81.4%
  • HTML 18.6%