Hello, i'm trying to only change a variable only when this column is focused, but it keeps getting the inicial last_location value when it is not focused.
PS: location is a state variable
Oh, thank you!. Could you explain to me why this works?
s
Sergey B
05/21/2021, 2:45 PM
Updating a state triggers re-composition. Changing a normal variable can't trigger re-composition. Therefore your Column composable is not getting re-composed.
PS. This is a good example of side-effects that you should avoid 🙂
https://developer.android.com/jetpack/compose/mental-model - this a very good article that explain how it works 🙂