I have a Swift ui view with a child witch gets values from a @State variable. When i update my @State variable the view rebuilds but the child stays the same.
struct ContentView: View {
@State var msg: String = ""
var body: some View {
VStack {
Button(action: {
self.msg = "Hallo World"
}, label: { Text("Say Hallo")})
ChildView(msg: msg).padding().background(Color.orange)
Text(msg).padding().background(Color.green)
}.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
struct ChildView: View {
@State var msg: String
var body: some View {
Text(msg)
}
}
