Closed Ivan5646 closed 5 years ago
Hi @Ivan5646,
You don't need this library to get window width or to handle window resizes.
There is a built-in JS method to work with window:
window.onresize = () => {
console.log(window.innerWidth);
console.log(window.innerHeight);
}
The main purpose of this library is to handle element resizes. But, if you want, you can always get window dimensions inside the callback
<ReactResizeDetector
handleWidth
handleHeight
render={({ width, height }) => (
<div>
Window width:{window.innerWidth}, height:{window.innerHeight}
</div>
)}
/>
But pay attention that this callback will be executed only when the parent div gets resized.
With this example I get the width of the parent component