I'd like to call parent View's function from Child View with parameters.
Following code is error.
struct ContentView: View {
func update(value: Double) {
print("called update: \(value)")
}
var body: some View {
ChildView(onUpdate: update)
}
}
struct ChildView: View {
var onUpdate: (value: Double) -> ()
var body: some View {
VStack {
Text("child view")
Button(action: {
self.onUpdate(value: 3.0)
}) {
Text("onUpdate")
}
}
}
}