@selfcommunity/react-core
Version:
React Core Components useful for integrating UI Community components (react-ui).
17 lines (16 loc) • 569 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = require("react");
function useResizeObserver(element, options, observerCallback) {
(0, react_1.useEffect)(() => {
if (!element || !('ResizeObserver' in window)) {
return undefined;
}
const observer = new ResizeObserver(observerCallback);
observer.observe(element, options);
return () => {
observer.disconnect();
};
}, [element, options, observerCallback]);
}
exports.default = useResizeObserver;
;