“Extra trialing closure passed in a call” error popped up when i use Task{} inside .onAppear{} .
.onAppear{
Task {
}
}
It was not giving an error till yesterday. But now i dont know what happened.
Can anyone explain this?
“Extra trialing closure passed in a call” error popped up when i use Task{} inside .onAppear{} .
.onAppear{
Task {
}
}
It was not giving an error till yesterday. But now i dont know what happened.
Can anyone explain this?
Welcome to the community! I wouldn’t expect an error here. Try to clean the project and build again
But there’s a .task { }
modifier you can use instead, that’s like the async version of .onAppear
Hi @Sanjeeb!
Having a Task inside onAppear
shouldn’t be a cause for error. There might be something in your code that caused the error.
As what @mikaelacaron have said, you can try putting all of your code from inside the Task closure into a .task { }
modifier instead of using .onAppear
.
/// instead of using:
View
.onAppear {
Task {
...
}
}
/// you can use:
View
.task {
...
}
Yup I think something else caused this, cause I added the same thing into my own project and there’s no error