mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-16 01:41:02 +08:00
61d0d6b182
* feat: useBreakpoint hook * update snapshots * update snapshots * update snapshots * add useBreakpoint hook test
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;
|