mirror of
https://github.com/towfiqi/serpbear
synced 2025-06-26 18:15:54 +00:00
- Replaces useEffet with useMemo & useLayoutEffect where necessary. - Converts some useEffects to separate hooks. - Moves the functions defined within components to utils. - Splits the Keywords renderPosition function to its own component.
13 lines
310 B
TypeScript
13 lines
310 B
TypeScript
import { useEffect, useState } from 'react';
|
|
|
|
const useIsMobile = () => {
|
|
const [isMobile, setIsMobile] = useState<boolean>(false);
|
|
useEffect(() => {
|
|
setIsMobile(!!(window.matchMedia('only screen and (max-width: 760px)').matches));
|
|
}, []);
|
|
|
|
return [isMobile];
|
|
};
|
|
|
|
export default useIsMobile;
|