mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-30 06:09:34 +08:00
19 lines
466 B
TypeScript
19 lines
466 B
TypeScript
|
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;
|