
Element Resize Observer Hook For React
A React hook that tracks changes to the dimensions of an element using the ResizeObserver API.
How to use it:
1. Install and import the React hook.
# NPM $ npm i resize-observer-hook --save
import useResizeObserver from 'resize-observer-hook'
2. Basic usage.
const App = () => { const [ref, width, height] = useResizeObserver() return ( <div ref={ref}> {width} X {height} </div> ) }
Preview:
Download Details:
Author: Gautam-Arora24
Live Demo: View The Demo
Download Link: Download The Source Code
Official Website: https://github.com/Gautam-Arora24/resize-observer-hook
License: MIT
Credit: Source link