Skip to content

Commit

Permalink
Merge pull request #29603 from pradeepmdk/fix/29464-console-error-cli…
Browse files Browse the repository at this point in the history
…ck-send-money

remove console error
  • Loading branch information
cristipaval authored Oct 16, 2023
2 parents 63af51e + 9a50fc8 commit b808ace
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
9 changes: 3 additions & 6 deletions src/pages/iou/ReceiptSelector/NavigationAwareCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ const propTypes = {

/* Callback function passing torch/flashlight capability as bool param of the browser */
onTorchAvailability: PropTypes.func,

/* Whether we're in a tab navigator */
isInTabNavigator: PropTypes.bool.isRequired,
};

const defaultProps = {
Expand All @@ -25,7 +22,7 @@ const defaultProps = {
};

// Wraps a camera that will only be active when the tab is focused or as soon as it starts to become focused.
function NavigationAwareCamera({torchOn, onTorchAvailability, ...props}, ref) {
const NavigationAwareCamera = React.forwardRef(({torchOn, onTorchAvailability, ...props}, ref) => {
const trackRef = useRef(null);
const isCameraActive = useIsFocused();

Expand Down Expand Up @@ -69,10 +66,10 @@ function NavigationAwareCamera({torchOn, onTorchAvailability, ...props}, ref) {
/>
</View>
);
}
});

NavigationAwareCamera.propTypes = propTypes;
NavigationAwareCamera.displayName = 'NavigationAwareCamera';
NavigationAwareCamera.defaultProps = defaultProps;

export default React.forwardRef(NavigationAwareCamera);
export default NavigationAwareCamera;
18 changes: 4 additions & 14 deletions src/pages/iou/ReceiptSelector/NavigationAwareCamera.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@ import {Camera} from 'react-native-vision-camera';
import {useTabAnimation} from '@react-navigation/material-top-tabs';
import {useNavigation} from '@react-navigation/native';
import PropTypes from 'prop-types';
import refPropTypes from '../../../components/refPropTypes';

const propTypes = {
/* The index of the tab that contains this camera */
cameraTabIndex: PropTypes.number.isRequired,

/* Forwarded ref */
forwardedRef: refPropTypes.isRequired,

/* Whether we're in a tab navigator */
isInTabNavigator: PropTypes.bool.isRequired,
};

// Wraps a camera that will only be active when the tab is focused or as soon as it starts to become focused.
function NavigationAwareCamera({cameraTabIndex, forwardedRef, isInTabNavigator, ...props}) {
const NavigationAwareCamera = React.forwardRef(({cameraTabIndex, isInTabNavigator, ...props}, ref) => {
// Get navigation to get initial isFocused value (only needed once during init!)
const navigation = useNavigation();
const [isCameraActive, setIsCameraActive] = useState(navigation.isFocused());
Expand Down Expand Up @@ -66,21 +62,15 @@ function NavigationAwareCamera({cameraTabIndex, forwardedRef, isInTabNavigator,

return (
<Camera
ref={forwardedRef}
ref={ref}
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
isActive={isCameraActive}
/>
);
}
});

NavigationAwareCamera.propTypes = propTypes;
NavigationAwareCamera.displayName = 'NavigationAwareCamera';

export default React.forwardRef((props, ref) => (
<NavigationAwareCamera
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
));
export default NavigationAwareCamera;

0 comments on commit b808ace

Please sign in to comment.