mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-15 17:19:11 +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;
|