Issue #685
Since we have custom init in ChildView
to manually set a State
, we need to pass ObservedObject
. In the ParentView, use underscore _
to access property wrapper type.
struct ChildView: View {
@ObservedObject
var store: Store
@State
private var selectedTask: AnyTask
init(store: ObservedObject<Store>) {
_selectedTask = State(initialValue: tasks.first!)
_store = store
}
}
struct ParentView: View {
@ObservedObject
var store: Store
var body: some View {
ChildView(store: _store)
}