nicodioso
(Nico Dioso)
1
I have a @BindingState which is accessed in a Component.
PickerSymbolSheet(isSelecting: viewStore.$isSelectingSymbol) { selectedSymbol in
viewStore.send(.setSymbol(selectedSymbol))
}
I wanted to set isSelectingSymbol manually via a button tap. I used this (and it works)
viewStore.send(.binding(.set(\.isSelectingSymbol, true)))
but it gives me a deprecated warning:
'set' is deprecated: For improved safety, bindable properties must now be wrapped explicitly in 'BindingState', and accessed via key paths to that 'BindingState', like '\.$value'
What's the updated way of doing this?
mbrandonw
(Brandon Williams)
2
The deprecation warning does describe to you exactly how to fix the problem. You want to use the \.$isSelectingSymbol key path instead of \.isSelectingSymbol.
nicodioso
(Nico Dioso)
3
Could you show my by code on how do I set that binding var?
You'll want to prepend the key path in the line giving you the warning:
-viewStore.send(.binding(.set(\.isSelectingSymbol, true)))
+viewStore.send(.binding(.set(\.$isSelectingSymbol, true)))
1 Like