forked from liftedinit/manifest-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: group pagination (liftedinit#92)
Co-authored-by: Felix C. Morency <[email protected]>
- Loading branch information
Showing
4 changed files
with
196 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useState, useEffect } from 'react'; | ||
|
||
const useIsMobile = (breakpoint: number = 1024) => { | ||
const [isMobile, setIsMobile] = useState(false); | ||
|
||
useEffect(() => { | ||
// Only run on client side | ||
if (typeof window === 'undefined') { | ||
return; | ||
} | ||
|
||
const checkIsMobile = () => { | ||
setIsMobile(window.innerWidth <= breakpoint); | ||
}; | ||
|
||
// Initial check | ||
checkIsMobile(); | ||
|
||
// Add event listener | ||
window.addEventListener('resize', checkIsMobile); | ||
|
||
// Cleanup | ||
return () => window.removeEventListener('resize', checkIsMobile); | ||
}, [breakpoint]); | ||
|
||
return isMobile; | ||
}; | ||
|
||
export default useIsMobile; |