Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 657 Bytes

README.md

File metadata and controls

29 lines (22 loc) · 657 Bytes

@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>
  );
}