I am trying to set the value of a @State var in an If statement that is inside of a struct of type :View, like so:
struct Name: View {
@State someVar: Int = 0
var body: some View {
VStack {
if this > that {
someVar = 1
But when I do this I get the error: "Type '()' cannot conform to 'View'; only struct/enum/class types can conform to protocols". If I use a class method that does what I need, like this:
if this > that {
someClass.doIt()
}
I get the same error.
What is the right way to do this?