SwiftPrettyPrint
SwiftPrettyPrint copied to clipboard
infinity-loop when include `@FocusState`
Inputing an object containing @FocusState
will cause an infinite loop.
A temporary fix to not output anything in FocusState object has been included in #182, but no fundamental fix has been made yet.
@YusukeHosonuma Can you provide a simple code sample to reproduce the event?
As follows.
import SwiftUI
import SwiftPrettyPrint
enum FocusableField: Hashable {
case email
case password
}
struct ContentView: View {
@FocusState private var focus: FocusableField?
var body: some View {
TextField("email", text: .constant(""))
.focused($focus, equals: .email)
.onChange(of: focus) { _ in
Pretty.prettyPrintDebug(self) // ⚠️ Occur infinity-loop when focus to `email` TextField.
}
}
}
