@State messing with initializer flow

Although that will compile, @State variables in SwiftUI should not be initialized from data you pass down through the initializer; since the model is maintained outside of the view, there is no guarantee that the value will really be used. The correct thing to do is to set your initial state values inline:

@State private var viewModel = SignInViewModel(...)

5 Likes