I have state data which is a collection of lists with key: values from json. I want to use ForEach View to show each list items in one list view but I'm getting Error. So I read that ForEach requires unique identifier, is there a hashable protocol for list like String and Int? Why am I getting this error?
Error:Cannot convert value of type 'Text' to closure result type '_'
struct PopUpTextView: View {
@State private var data = [[String:Any]]()
//let colors: [[String]] = [["red", "blue"], ["tan"],["green"], ["blue"]]
func configureView() {
takeRequest { (data, error) in
print("before")
print(data)
self.data = data
print("------")
print(self.data)
}
}
var body: some View {
NavigationView{
List{
ForEach(self.$data, id: \.self){ c in
Text(c.description)
}
}.navigationBarTitle("Details")
}.onAppear(perform:configureView)
}
}