Hi folks. Is there any recommended way to change multiple mutableState variables in one transaction? the second variable i change doesn't seem to cause a re-render
๐ 1
f
Filip Wiesner
12/12/2023, 2:44 PM
way to change multiple mutableState variables in one transaction
This should work:
Copy code
Snapshot.withMutableSnapshot { }
But that the second variable not causing re-rendering might be a different problem ๐ค
โ๐ป 1
v
vide
12/12/2023, 2:45 PM
if you're running on the main thread you shouldn't need to use withMutableSnapshot
๐ 1
๐๐ป 1
๐๐พ 1
z
Zach Klippenstein (he/him) [MOD]
12/12/2023, 4:18 PM
Yep if youโre changing it on the main thread and something isnโt invalidating like you expect, using an explicit snapshot probably wonโt help since the two states are probably read in separate invalidation scopes, which will still invalidate independently regardless of which snapshot application does so.
s
stantronic
12/12/2023, 5:42 PM
Turns out it was a silly coding error on my part ๐คฆ wasn't reading my own code carefully enough - i was never passing the altered variable into the component. Now all works as expected. Thanks anyway