mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 09:49:57 +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;
|