add useBreakpoint hook
This commit is contained in:
25
src/hooks/useBreakPoint.ts
Normal file
25
src/hooks/useBreakPoint.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { Grid } from "antd";
|
||||||
|
|
||||||
|
const { useBreakpoint } = Grid;
|
||||||
|
|
||||||
|
export default function useBreakPoint() {
|
||||||
|
const { xs, sm, md } = useBreakpoint();
|
||||||
|
|
||||||
|
if (xs)
|
||||||
|
return {
|
||||||
|
isDesktop: false,
|
||||||
|
isMobile: true,
|
||||||
|
isTablet: false,
|
||||||
|
};
|
||||||
|
if (md || sm)
|
||||||
|
return {
|
||||||
|
isDesktop: false,
|
||||||
|
isMobile: false,
|
||||||
|
isTablet: true,
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
isDesktop: true,
|
||||||
|
isMobile: false,
|
||||||
|
isTablet: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user