Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove console error #29603

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading