At the moment I have a ForEach loop like this:
ForEach(viewModel.data, id: \.self) { data in
Button(action: {
self.isPresented.toggle()
}, label: {
HomepageRow(data: data)
})
.sheet(isPresented: $isPresented) {
DetailView(data: data)
}
}
And i need to pass data to my DetailView which has a var data: MyStruct
this works fine, the problem is that when I tap back and I open another detailview, the new data is not passed. I know sheet doesnt trigger .onAppear of the mainView, so my question is, how do I pass different data based on the ForEach element tapped?
I can observe the same behavior with the new iOS 14.0 fullScreenCover.
This is the struct:
}).fullScreenCover(isPresented: $isPresented) {
print("DISMISSED")
} content: {
DetailView(data: data)
}
So what is the best approach to pass new data once the sheet or fullScreenCover are dismissed?