Open rosentoshev opened 4 years ago
@rosenexpend So the issue happens primarily on the second time the camera is opened correct? I've experienced some weirdness with react native navigation and mounting/unmounting components. Like when navigating away from the view with the camera, the camera doesn't always get unmounted. If you use the lifecycle hooks that react-native-navigation offers for navigating away from the camera, you can unmount the camera and it should work. I primarily use this package in modals so that when the modal/view is dismissed the camera gets unmounted fully (not just put into a background view waiting for the user to navigate back to it).
Does that help?
Thank you @humphreyja. I will try unmounting the camera, when navigating away from the page and will let you know.
@humphreyja I resolved this issue by setting an if
statement to show or hide the scanner in the onBack()
function that handles the back button.
this.setState({hideCamera:true})
...
render() {
if (this.state.hideCamera) {
return null;
}
return(
...
)
I have a very similar issue to this one. However, the PR that seems to have solved it for the person raising the issue is not working for me as my version of the rectangle scanner is the latest one:
1.0.10
. The device that I am using is iPhone 6s, iOS 14.1. However, other test users had the same issue with iPhone 11 and other devices. The navigation used in the app isreact-native-navigation
.The initial time that the scanner is launched is usually alright. Then when I navigate away from the screen and relaunch the viewer freezes. I can still take the image blindly and it would accurately reflect where the camera is pointing to. I made a test repo, which exhibits a similar pattern of behavior. The code for my Rectangle Scanner in the test repo is: