Resolving Critical QR Scanner Bug: Enhancing Event Check-In HUDResolving Critical QR Scanner Bug: Enhancing Event Check-In HUD
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started
@figma x @contra #configmakeathon Minor update: I finally got the QR Code scanner in the Check-In HUD tab to be fed live data from the current device's camera and the canvas needs to be alive.
Faced a few difficulties implimenting this, but I finally got it right. The QR scanner had a critical bug: the scan function was wrapped in useCallback with [onScan] as dependency. The useEffect depended on [scan]. This created a situation where:
Every time onScan prop changed reference (which happens on every render since onScan is an inline arrow function), scan got recreated.
useEffect then re-ran, stopping and restarting the camera/scan loop.
This caused an infinite restart loop.
But more critically, the scan function was used as a useCallback but useEffect also depended on scan.
When the parent component passed a new onScan reference on each render, it triggered scan to be recreated, which then caused the effect to re-run and start a fresh camera stream every time. This created multiple overlapping streams and breaks the scanner functionality.
The solution was to move scan directly into the useEffect so it's not a separate dependency, and use a ref to store the onScan callback to prevent unnecessary recreations.
The root bug: scan was in useCallback([onScan]) and useEffect([scan]).
Next? I'll be fixing the register for event process (from the landing) and also the copy event link button at the top right corner of the event card modal, to display a link and ID needed by a user so they can be ale to find and register for an event.
@_radnolan #ConfigMakeathon #buildinpublic @tranmautritam @janm_uiux @thedesignely
Monic's avatar
MNC logo
this seems to be shaping up well!
Divine's avatar
It really is, Monic. I' working on a few more adjustements and refinements.:
harshad's avatar
Divine's avatar
Thank you, Harshad.
Back to feed
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started