Hi folks. Is there any recommended way to change multiple mutableState variables in one transaction?...
s
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
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
if you're running on the main thread you shouldn't need to use withMutableSnapshot
๐Ÿ‘† 1
๐Ÿ‘†๐Ÿป 1
๐Ÿ‘†๐Ÿพ 1
z
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
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
๐Ÿ‘๐Ÿป 1
๐Ÿ‘๐Ÿผ 1
๐Ÿ‘๐Ÿพ 1