Skip to content

Commit

Permalink
change to more robust mobile check
Browse files Browse the repository at this point in the history
  • Loading branch information
moe-dev committed Dec 18, 2024
1 parent f52b04f commit 69979f0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions examples/react-components/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,20 @@ export default function AuthPage() {

useEffect(() => {
const checkMobile = () => {
setIsMobile(window.innerWidth <= 768);
setShowContent(window.innerWidth > 768);
const userAgent = navigator.userAgent || navigator.vendor;
const mobileRegex =
/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i;
setIsMobile(mobileRegex.test(userAgent.toLowerCase()));
};
checkMobile();
window.addEventListener("resize", checkMobile);
return () => window.removeEventListener("resize", checkMobile);
}, []);

useEffect(() => {
if (isMobile) {
setShowContent(false);
}
}, [isMobile]);
useEffect(() => {
const manageSession = async () => {
if (turnkey) {
Expand Down

0 comments on commit 69979f0

Please sign in to comment.