Skip to content

Commit

Permalink
Merge pull request #396 from kshahzada/master
Browse files Browse the repository at this point in the history
Updated Camera object to be instance of forwardRef function
  • Loading branch information
aarongrider authored May 25, 2021
2 parents 3208896 + 60ab3c4 commit f35ed93
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Camera.android.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { requireNativeComponent, findNodeHandle, NativeModules, processColor } f
const { RNCameraKitModule } = NativeModules;
const NativeCamera = requireNativeComponent('CKCameraManager');

function Camera(props, ref) {
const Camera = React.forwardRef((props, ref) => {
const nativeRef = React.useRef();

React.useImperativeHandle(ref, () => ({
Expand All @@ -32,10 +32,10 @@ function Camera(props, ref) {
ref={nativeRef}
{...transformedProps}
/>);
}
});

const { PORTRAIT, PORTRAIT_UPSIDE_DOWN, LANDSCAPE_LEFT, LANDSCAPE_RIGHT } = RNCameraKitModule.getConstants();

export { PORTRAIT, PORTRAIT_UPSIDE_DOWN, LANDSCAPE_LEFT, LANDSCAPE_RIGHT };

export default React.forwardRef(Camera);
export default Camera;
6 changes: 3 additions & 3 deletions src/Camera.ios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { requireNativeComponent, NativeModules, processColor } from 'react-nativ
const { CKCameraManager } = NativeModules;
const NativeCamera = requireNativeComponent('CKCamera');

function Camera(props, ref) {
const Camera = React.forwardRef((props, ref) => {
const nativeRef = React.useRef();

React.useImperativeHandle(ref, () => ({
Expand All @@ -24,12 +24,12 @@ function Camera(props, ref) {
_.update(transformedProps, 'cameraOptions.ratioOverlayColor', (c) => processColor(c));

return <NativeCamera style={{ minWidth: 100, minHeight: 100 }} ref={nativeRef} {...transformedProps} />;
}
});

Camera.defaultProps = {
resetFocusTimeout: 0,
resetFocusWhenMotionDetected: true,
saveToCameraRoll: true,
};

export default React.forwardRef(Camera);
export default Camera;

0 comments on commit f35ed93

Please sign in to comment.