Closed pfeigl closed 2 years ago
For reproducing the original problem: Just serve the stencil app and take a photo. For me it gives this every time:
Background is, that here https://github.com/ionic-team/pwa-elements/blob/6e1394a00b891a0242fea1f41b151681f1012d2a/src/components/camera/camera.tsx#L436
photoSrc might not be set already, while photo is already set.
Is there anything we can do, to get this merged?
Help? ;-(
Thanks for the PR!
I've merged another one that also fixed the issue in a different way, so closing this one.
Stencil used to remove console logs in production, but not anymore. I will switch them to console.debug as they are still helpful while in development and stencil removes them when doing a production build
The UI re-render's as soon as
this.photo
is set, as it's annotaed with@State
.The problem comes up when the UI renders faster as
getOrientation
and the following setting ofthis.photoSrc
can execute (which happens reproducible for me).With the UI already rendering and
photoSrc
not beeing set, theaccept-image
tries to requestundefined
.To fix this, I moved setting
this.photo
to the end ofpromptAccept
.I did the following additional changes:
@State
fromphotoSrc
to save one redundant render cycle (and be consistent withphotoOrientation
)console.log
to keep the console clean in production apps.