You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Open view using a navigation link that contains the CodeScannerView which shows an alert using a state boolean if there is not camera access (see code below).
Expected: The alert appears
Actual: No alert is shown and an error is logged: [SwiftUI] Modifying state during view update, this will cause undefined behavior.
Workaround: Set the change to the alert bool in a new main actor task
// DetailCameraView.swift
import SwiftUI
import CodeScanner
structDetailCameraView:View{@StateprivatevarshowNoCameraAccess=falsevarbody:someView{CodeScannerView(codeTypes:[.qr]){ result inswitch result {case.success(_):print("Success")case.failure(_):
// Task { @MainActor in // Workaround
showNoCameraAccess =true
// }
}}.alert("No Camera Access", isPresented: $showNoCameraAccess){
// OK button is shown by default
}}}
The text was updated successfully, but these errors were encountered:
CodeScannerView
which shows an alert using a state boolean if there is not camera access (see code below).Expected: The alert appears
Actual: No alert is shown and an error is logged:
[SwiftUI] Modifying state during view update, this will cause undefined behavior.
Workaround: Set the change to the alert bool in a new main actor task
Code to reproduce the issue:
The text was updated successfully, but these errors were encountered: