UNPKG

@lobehub/charts

Version:

React modern charts components built on recharts

15 lines 465 B
import { useEffect } from 'react'; import { isOnSeverSide } from "../utils"; export var useOnWindowResize = function useOnWindowResize(handler) { useEffect(function () { if (isOnSeverSide) return; var handleResize = function handleResize() { handler(); }; handleResize(); window.addEventListener('resize', handleResize); return function () { return window.removeEventListener('resize', handleResize); }; }, [handler]); };