React hook to handle DOM element size
npm install react-hook-sizenpm i react-hook-size --save
javascript
import React, { useRef } from 'react';
import { useSize } from 'react-hook-size';
export default function Example() {
let style = {
width: '100%',
height: '100%',
};
let ref = useRef();
let { width, height } = useSize(ref);
return (
W: {width}, H: {height}
);
}
``