Skip to content

fix: prevent state updates in parent while rendering qrcodescanner#196

Merged
im-adithya merged 1 commit intomasterfrom
task-qr-scanner
Nov 22, 2024
Merged

fix: prevent state updates in parent while rendering qrcodescanner#196
im-adithya merged 1 commit intomasterfrom
task-qr-scanner

Conversation

@im-adithya
Copy link
Copy Markdown
Member

Description

Issue

This is logged when a QR is scanned:
Warning: Cannot update a component (SetupWallet) while rendering a different component (QRCodeScanner). To locate the bad setState() call inside QRCodeScanner, follow the stack trace as described in https://reactjs.org/link/setstate-in-render

The fix

Updater functions run during rendering, and that causes state updates in the parent as we are calling onScanned, so this moves that out to check isScanning and then proceed so that the logic is same but it is just moved outside the updater function

@im-adithya im-adithya merged commit 93d709b into master Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant