helium / maker-starter-app

Apache License 2.0
36 stars 39 forks source link

Runtime error when opening page HotspotSetupExternalScreen.tsx (add an hotspot with QR onboarding) #50

Closed LeoUbl closed 1 year ago

LeoUbl commented 1 year ago

I think this error can occur to everyone with the default code, but tell me if this doesn't happen to you, maybe it's my fault. The app compiles normally, I open the app, tap on Add hotspot, tap on Example QR Hotspot, the error occurs. The app crashes and the error was something like "undefined is not a function". So I checked the code with VSCode and in /maker-starter-app/src/features/hotspots/setup/HotspotSetupExternalScreen.tsx in line 8 there's the import of usePermissions from expo-barcode-scanner. Here VSCode says that the library doesn't have any export of usePermissions. I checked the code of expo-barcode-scanner and I see that usePermissions is defined inside BarCodeScanner which the app already imports. So I fixed the error by commenting the import of usePermissions and in line 40 I added "BarCodeScanner." before usePermissions. This is the resulting code after my edits:

import {
  BarCodeScanner,
  BarCodeScannerResult,
  // usePermissions,
} from 'expo-barcode-scanner'

...

const [perms] = BarCodeScanner.usePermissions({
    request: true,
  })

This fixed the error, so now when I tap on Example QR Hotspot the app asks the permissions correctly and then shows the expected page.

Please let me know if this is a common problem and if you are going to include this fix. Thanks

LeoUbl commented 1 year ago

I'm closing this since with the latest version the error is fixed