Using 'true' or 'false' works as expected:
TextEditor(text: $input)
.autocorrectionDisabled(true)
But when replacing with a State variable, only the initial value is used. When the state value changes to 'false', the behavior of autocorrect doesn't change.
@State var shouldDisable = true
TextEditor(text: $input)
.autocorrectionDisabled(shouldDisable)
.onReceive(aTimer) { \_ in
if otherConditionMet {
withAnimation {
shouldDisable = false
}
print(shouldDisable)
}
}
The timer is firing every second to evaluate if otherConditionMet. Here's the output of the simple print statement confirming shouldDisable updates when the other condition is met:
`shouldDisable: true`
`shouldDisable: true`
`shouldDisable: true`
`shouldDisable: true`
`shouldDisable: true
`shouldDisable: false`
`shouldDisable: false`
`shouldDisable: false`
I've validated by initialing 'shouldDisable' to true and again initializing to false and swapping shouldDisable = true in the if statement. In both conditions, only the initial value is used, despite how the variable changes.
Thanks for any input!