Version: v3.6.0

@rooks/use-mouse#

Mouse position hook for React.#


Build Status

Installation#

npm install --save @rooks/use-mouse

Importing the hook#

import useMouse from "@rooks/use-mouse"

Usage#

function Demo() {
const { x, y } = useMouse();
return (
<>
<p> Move mouse here to see changes to position </p>
<p>X position is {x || "null"}</p>
<p>X position is {y || "null"}</p>
</>
);
}
render(<Demo/>)

Returned Object#

Returned object attributesTypeDescription
xintX position of mouse
yintY position of mouse
Last updated on by imbhargav5