Closed johnhunter closed 4 years ago
@johnhunter you can create and pass your own ref to the ReactResizeDetector
in case you need to process it somehow.
For example
const ref = createRef(); // or useRef();
<ReactResizeDetector targetRef={ref} onResize={() => /* do something with ref */}>
{() => <div ref={ref}>...</div>}
</ReactResizeDetector>
The main idea is to handle refs inside the library and to pass them as parameters if you don't want to create your own ref (less code, fewer rules). But if you do need to work with these refs you should create your own instances and pass them inside ReactResizeDetector.
Great, thanks!
Now that v5.x.x provides a
targetRef
property it would be useful if theref
could be passed as an argument in theonResize
callback.For example: