I have an array with 10 different categories. So I create NavigationLink for each of them, calling MyListView and passing data about the category.
NavigationView {
List(categories) { category in
NavigationLink(destination:
MyListView(category: category)
)
{
CategoryRow(category: category)
}
}
}
So when I click in one of these 10 categories, I will call MyListView. Inside MyListView I have a call to the API bringing a lot of information about the chosen category.
The problem here is, even before clicking in any category, MyListView is being called and the API is called for all the 10 categories.
I only want to call MyListView and the API inside it, after selecting the category.
Whats the problem here ?
Thx