diff --git a/src/use-device-permission.ts b/src/use-device-permission.ts index c1453a41..554e6641 100644 --- a/src/use-device-permission.ts +++ b/src/use-device-permission.ts @@ -1,10 +1,16 @@ import { useEffect, useState } from "react"; -export const useDevicePermissions = () => { +export const useDevicePermissions = ({ + continueToApp, +}: { + continueToApp: boolean; +}) => { const [permission, setPermission] = useState(false); const [denied, setDenied] = useState(false); useEffect(() => { + if (!continueToApp) return; + navigator.mediaDevices .getUserMedia({ audio: true, video: false }) .then(() => { @@ -15,7 +21,7 @@ export const useDevicePermissions = () => { setDenied(true); setPermission(false); }); - }, []); + }, [continueToApp]); return { permission, denied }; };