Closed roydukkey closed 3 years ago
I'm not sure I get the idea. Can you maybe provide a more detailed explanation or code snippet? Or maybe create a pull request on this?
I'll create a PR. For instance:
import { useResizeDetector } from 'react-resize-detector';
import type { UseResizeDetectorReturn } from 'react-resize-detector';
let resizeDetector: UseResizeDetectorReturn<HTMLElement>;
export default function SingletonComponent(): JSX.Element {
resizeDetector = useResizeDetector<HTMLElement>();
// ...
}
export function useComponentSize () {
// Do work with `resizeDetector`
}
Currently, this is how it has to be done. But, this involves poking around the internals of the library more so than the suggested changes.
let resizeDetector: { ref: MutableRefObject<HTMLElement | null>; height?: number; width?: number; };
Thank you! Merged and published 6.7.6
Could we get an interface for this return? This would be useful when storing the result, instead of destructuring it.
https://github.com/maslianok/react-resize-detector/blob/6d7c8a5923b1165773038c7994eed9657b58a825/src/useResizeDetector.ts#L76