I have a store, but need to call the method inside the body. However the only way it works is if I call it inside init otherwise I have an error.
@ObservedObject var store = MyStore()
init(category: categoryModel) {
store.getData(categoryId: category.id) //here works
}
var body: some View {
store.getData(categoryId: category.id) //Here I will have the error: Type '()' cannot conform to 'View'
Why ? Thx