ant-design/components/grid/hooks/useBreakpoint.tsx

19 lines
466 B
TypeScript
Raw Normal View History

import { useEffect, useState } from 'react';
import ResponsiveObserve, { ScreenMap } from '../../_util/responsiveObserve';
function useBreakpoint(): ScreenMap {
const [screens, setScreens] = useState<ScreenMap>({});
useEffect(() => {
const token = ResponsiveObserve.subscribe(supportScreens => {
setScreens(supportScreens);
});
return () => ResponsiveObserve.unsubscribe(token);
}, []);
return screens;
}
export default useBreakpoint;