add more hooks

This commit is contained in:
Nate Kelley 2025-03-18 14:26:19 -06:00
parent 96731d86d0
commit fd8a461d7a
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
3 changed files with 23 additions and 11 deletions

View File

@ -1,11 +0,0 @@
https://react-grid-layout.github.io/react-grid-layout/examples/20-resizable-handles.html
https://gridstackjs.com/demo/nested.html#
https://strml.github.io/react-resizable/examples/1.html
https://bokuweb.github.io/re-resizable/?path=/story/multiple--horizontal

View File

@ -22,3 +22,4 @@ export * from './useScroll';
export * from './useUpdateEffect';
export * from './useWhyDidYouUpdate';
export * from './useSetInterval';
export * from './useWindowWidth';

View File

@ -0,0 +1,22 @@
import { useState, useEffect } from 'react';
export const useWindowWidth = () => {
const [isMobile, setIsMobile] = useState(false);
useEffect(() => {
const checkWidth = () => {
setIsMobile(window.innerWidth < 900);
};
// Initial check
checkWidth();
// Add event listener
window.addEventListener('resize', checkWidth);
// Cleanup
return () => window.removeEventListener('resize', checkWidth);
}, []);
return isMobile;
};