Skip to content

tranbathanhtung/usePosition

Repository files navigation

@rehooks/usePosition

React hook for ...

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/usePosition

Usage

import { useRef } from 'react';
import usePosition from '@rehooks/usePosition';

function MyComponent() {
  let ref = useRef(null);
  let { left, top } = usePosition(ref);
  return (
    <p ref={ref}>Hello Hooks: {JSON.stringify({left, top})}</p>
  );
}

About

React hook for get position of element

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published