ideas icon indicating copy to clipboard operation
ideas copied to clipboard

usePosition

Open tranbathanhtung opened this issue 6 years ago • 0 comments

A simple hook to get position of a element

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

here my repo: https://github.com/tranbathanhtung/usePosition

tranbathanhtung avatar Oct 29 '18 13:10 tranbathanhtung