Skip to content

armgit / meet

Public Imported from GitHub
0

Open source video conferencing app powered by LiveKit. Built with Django and React.

✨(front) add useIsMobile hook

Nathan Vassedb1fdb987124
diff --git a/src/frontend/src/utils/useIsMobile.ts b/src/frontend/src/utils/useIsMobile.ts
new file mode 100644
index 00000000..63054573
--- /dev/null
+++ b/src/frontend/src/utils/useIsMobile.ts
@@ -0,0 +1,20 @@
+import { isMobileBrowser } from '@livekit/components-core'
+import { useEffect, useState } from 'react'
+
+export const useIsMobile = () => {
+ const [isMobile, setIsMobile] = useState(isMobileBrowser())
+
+ useEffect(() => {
+ const handleResize = () => {
+ setIsMobile(isMobileBrowser())
+ }
+
+ window.addEventListener('resize', handleResize)
+
+ return () => {
+ window.removeEventListener('resize', handleResize)
+ }
+ }, [])
+
+ return isMobile
+}