-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add useIsMobile hook, isMobile prop, enhance ui style
- Loading branch information
1 parent
fee3fbd
commit 8bd3f16
Showing
6 changed files
with
80 additions
and
6 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,22 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
const useIsMobile = () => { | ||
const [isMobile, setIsMobile] = useState(false); | ||
|
||
useEffect(() => { | ||
const handleResize = () => { | ||
setIsMobile( | ||
window.matchMedia("only screen and (max-width: 912px)").matches, | ||
); | ||
}; | ||
|
||
window.addEventListener("resize", handleResize); | ||
handleResize(); // Chiamare la funzione quando il componente viene montato | ||
|
||
return () => window.removeEventListener("resize", handleResize); | ||
}, []); | ||
|
||
return isMobile; | ||
}; | ||
|
||
export default useIsMobile; |
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