-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(j-s): Enable opening uploaded files on iOS (#17400)
* Enable opening uploaded files on iOS * Add SSR check --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
c257544
commit f643adc
Showing
2 changed files
with
33 additions
and
2 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
25 changes: 25 additions & 0 deletions
25
apps/judicial-system/web/src/utils/hooks/useIsMobile/useIsMobile.ts
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,25 @@ | ||
import { useEffect, useState } from 'react' | ||
|
||
const useIsMobile = () => { | ||
const [isMobile, setIsMobile] = useState(false) | ||
|
||
useEffect(() => { | ||
const checkMobile = () => { | ||
// Check for SSR | ||
if (!window) { | ||
return false | ||
} | ||
|
||
const userAgent = navigator.userAgent | ||
const mobileRegex = | ||
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i | ||
return mobileRegex.test(userAgent) | ||
} | ||
|
||
setIsMobile(checkMobile()) | ||
}, []) | ||
|
||
return isMobile | ||
} | ||
|
||
export default useIsMobile |