expo: [SDK44][bare-code-scanner][Android] QR Code not working after using "back" button
Summary
When using “bare-code-scanner”, after scanning a QR Code then navigate to a result page if I hit “back” button no more QR is scanned. On iOS QR code is well scanned in this case.
Behavior:
Case 1 (Bug):
- Scanning a QR & display my result screen
- Click back button
- Trying scanning another QR = Not detected
Case 2:
- Scanning a QR & display my result screen
- Click back button (so back to my “camera screen”) then back again to my main screen
- Click on “Scan QR” button
- Scanning a QR = Detected then display my result screen
This issue is opened following this thread: https://github.com/expo/expo/pull/15393
Managed or bare workflow? If you have ios/
or android/
directories in your project, the answer is bare!
managed
What platform(s) does this occur on?
Android
SDK Version (managed workflow only)
44
Environment
Expo CLI 5.0.3 environment info:
System:
OS: Windows 10 10.0.19044
Binaries:
Node: 14.17.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.13 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 4.0.0.0 AI-193.6911.18.40.6626763
npmPackages:
expo: ~44.0.0 => 44.0.1
react: 17.0.1 => 17.0.1
react-dom: 17.0.1 => 17.0.1
react-native: 0.64.3 => 0.64.3
react-native-web: 0.17.1 => 0.17.1
react-navigation: ^4.4.4 => 4.4.4
Expo Workflow: managed
Reproducible demo
You can find a reproducible demo here:
https://snack.expo.dev/@fabzien/bare-code-scanner-report-issue
To reproduce (Android only):
- Click “Go to QRCodeScanner”
- Scan any QR Code
- Click “Back” on next screen
- Click “Tap to Scan Again”
- Try to scan another QR code = Failed
SDK 44 isn’t supported on Snack so it’s using SDK 33 but you can import it then upgrade to SDK 44.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 7
- Comments: 20 (2 by maintainers)
A workaround would be to give the
Camera
component akey
prop.onBarCodeScanned
triggers akey
value modification which rerenders theCamera
. TheCamera
is reset and able to scan again.Hope it helps
I am on expo
44.0.3
and expo-barcode-scanner1.2.0
and I confirm that after pressing back button the scanner does not work anymore.I am on expo 44.0.4 and"expo-barcode-scanner": “~11.2.0” and I have the same problem when I change of screen the scanner does not work I think its something in onBarCodeScanned prop
@Fabzien thank you
I just want to clarify for everyone that this workaround doesn’t actually fix the behavior where an instance will only scan one barcode.
If you restart the component by going back / reloading etc, then yes it will scan a 2nd one. But the BarCodeScanner works perfectly - just not the camera.
This Solved “between screens” problem.
import { useIsFocused } from '@react-navigation/native';
const isFocused = useIsFocused();
return(
{isFocused &&
<Camera />
}
)
I’m having the same issue, I’m on expo: 44.0.0 expo-camera: 12.1.2 expo-barcode-scanner: 11.2.0
I’m having the same issue, I’m on
expo
: 44.0.6expo-camera
: 12.1.2expo-barcode-scanner
: 11.2.1