Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tranbathanhtung/usePosition
React hook for get position of element
https://github.com/tranbathanhtung/usePosition
Last synced: about 2 months ago
JSON representation
React hook for get position of element
- Host: GitHub
- URL: https://github.com/tranbathanhtung/usePosition
- Owner: tranbathanhtung
- License: mit
- Created: 2018-10-29T13:05:19.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-29T13:06:29.000Z (about 6 years ago)
- Last Synced: 2024-08-01T02:25:37.699Z (4 months ago)
- Language: JavaScript
- Size: 61.5 KB
- Stars: 23
- Watchers: 1
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- fucking-awesome-react-hooks - `usePosition`
- awesome-react-hooks-cn - `usePosition`
- awesome-react-hooks - `usePosition`
- awesome-react-hooks - `usePosition`
README
# `@rehooks/usePosition`
> React hook for ...
> **Note:** This is using the new [React Hooks API Proposal](https://reactjs.org/docs/hooks-intro.html)
> 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
```sh
yarn add @rehooks/usePosition
```## Usage
```js
import { useRef } from 'react';
import usePosition from '@rehooks/usePosition';function MyComponent() {
let ref = useRef(null);
let { left, top } = usePosition(ref);
return (
Hello Hooks: {JSON.stringify({left, top})}
);
}
```