SwiftUI – updating @State is not changing the view

you just made a minor mistake.

In customloginField, you need to define inputStr: String as a binding variable

@Binding var inputStr:String

and while using, you have to use it as following

CustomLoginField(inputStr:self.$phone, keyboard: .numberPad, placeholder:"PHONE", formatedPhoneNumber:true, maxLength: 10)
CustomLoginField(inputStr:self.$password, keyboard: .numberPad, placeholder: "PASSWORD", isSecure: true, maxLength: 4)

Noticed “$” before phone & password?

Check below SO thread for the @state vs @binding SwiftUI @State vs Binding

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top