popstellar icon indicating copy to clipboard operation
popstellar copied to clipboard

[BUG] Fix QrCodeScanner implementation

Open Tyratox opened this issue 3 years ago • 2 comments

Description (Actual behavior)

It seems as if the onBarCodeScanned handle function is only set initially by expo-camera and if the passed prop changes, this is ignored. Hence variables such as the current list of attendees referenced by the function won‘t update. The following snack also shows this issue: https://snack.expo.dev/0MS_5nPEp. Observe the counter value after scanning a few qr codes. Previously this problem did not occur since setState(oldState => …) was used where oldState received in the callback is always the latest and the reference to setState did not change. PR #1303 worked around this issue by additionally using a mutable reference that allows for proper duplicate checking which most likely was broken since the migration to react-camera. This implementation is hacky and should be fixed as soon as the issue is fixed upstream in react-camera.

Version & Environment

This bug was reproduced on:

  • Commit: cd9b866230658310ab57621b34b2c1a69ec612ae
Front-ends:
  • [x] Fe1-Web (please include browser's names & version)
  • [ ] Fe2-Android (please specify if phone or emulation, and Android version)
  • [ ] Not applicable
Back-ends:
  • [ ] Be1-Go
  • [ ] Be2-Scala
  • [x] Not applicable

Tyratox avatar Dec 05 '22 07:12 Tyratox

@Tyratox I seem to recall you had found a few resources/issues mentioning this upstream bug. Could you reference them in this issue for future reference ? Thanks !

pierluca avatar Dec 08 '22 22:12 pierluca

I just created an issue with a better snack here: https://github.com/expo/expo/issues/20404

I did not find an existing issue mentioning the exact same bug.

Tyratox avatar Dec 09 '22 08:12 Tyratox