You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
466 B
19 lines
466 B
5 years ago
|
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;
|