Skip to content

Commit bbdce8c

Browse files
committed
Fix web camera not loading
1 parent ef6203d commit bbdce8c

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/pages/iou/request/step/IOURequestStepScan/NavigationAwareCamera/WebCamera.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1+
import {useIsFocused} from '@react-navigation/native';
12
import React from 'react';
23
import type {ForwardedRef} from 'react';
34
import {View} from 'react-native';
45
import type {Camera} from 'react-native-vision-camera';
56
import Webcam from 'react-webcam';
6-
import useTabNavigatorFocus from '@hooks/useTabNavigatorFocus';
77
import type {NavigationAwareCameraProps} from './types';
88

99
// Wraps a camera that will only be active when the tab is focused or as soon as it starts to become focused.
1010
function WebCamera({torchOn, onTorchAvailability, cameraTabIndex, ...props}: NavigationAwareCameraProps, ref: ForwardedRef<Webcam | Camera>) {
11-
const shouldShowCamera = useTabNavigatorFocus({
12-
tabIndex: cameraTabIndex,
13-
});
11+
const shouldShowCamera = useIsFocused();
1412

1513
if (!shouldShowCamera) {
1614
return null;

src/pages/iou/request/step/IOURequestStepScan/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {useIsFocused} from '@react-navigation/native';
12
import {Str} from 'expensify-common';
23
import React, {useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState} from 'react';
34
import {ActivityIndicator, PanResponder, PixelRatio, View} from 'react-native';
@@ -24,7 +25,6 @@ import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalD
2425
import useLocalize from '@hooks/useLocalize';
2526
import usePolicy from '@hooks/usePolicy';
2627
import useResponsiveLayout from '@hooks/useResponsiveLayout';
27-
import useTabNavigatorFocus from '@hooks/useTabNavigatorFocus';
2828
import useTheme from '@hooks/useTheme';
2929
import useThemeStyles from '@hooks/useThemeStyles';
3030
import * as Browser from '@libs/Browser';
@@ -92,7 +92,7 @@ function IOURequestStepScan({
9292

9393
const [videoConstraints, setVideoConstraints] = useState<MediaTrackConstraints>();
9494
const tabIndex = 1;
95-
const isTabActive = useTabNavigatorFocus({tabIndex});
95+
const isTabActive = useIsFocused();
9696

9797
const isEditing = action === CONST.IOU.ACTION.EDIT;
9898
const defaultTaxCode = TransactionUtils.getDefaultTaxCode(policy, transaction);

0 commit comments

Comments
 (0)