https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
k

kevin.cianfarini

02/10/2023, 10:44 PM
Something lacking proper keys, eg:
Copy code
class Presenter {
  @Composable fun foo() {
    var state by remember { mutableStateOf(1) }
  }
}
could be conflated (stale?) between different instances of presenter. Eg. two separate instances of
Presenter
would read from and mutate the same state variable. You would conceptually think that states would normally be isolated since they belong to different object instances, but the way compose tracks things keyed in the slot table doesn't care about OOP. keying the state by
this
fixes this.
2 Views