22.2 State Binding
A state property is local to the view in which it is declared and any child views. Situations may occur, however, where a view contains one or more subviews which may also need access to the same state properties. Consider, for example, a situation whereby the Wi-Fi Image view in the above example has been extracted into a subview:
.
.
VStack {
Toggle(isOn: $wifiEnabled) {
Text("Enable WiFi")
}
TextField("Enter user name", text: $userName)
WifiImageView()
}
}
.
.
struct WifiImageView: View {
var body: some View {
...