Tristan
11/30/2020, 2:38 PMby state
and remember
differences. Could someone guide me towards some documentation about it?Marko Novakovic
11/30/2020, 2:50 PMremember
is tied up to composable itself. it serves to "survive" recomposition
but when composable
is removed from the screen remembered value is forgotten 😄. by state
is used to store state
and you can use it with observer pattern or hoist
it to a higher pointTristan
11/30/2020, 3:27 PMremember
is limited to the scope of the component. If the component is destroyed, there will be nothing to remember.
The state is something external to the component, if the component is destroyed, but recreated later, it will get the same state than the previous destroyed component?Marko Novakovic
11/30/2020, 3:28 PMallan.conda
11/30/2020, 3:33 PMTristan
12/01/2020, 2:36 PMremember { mutableStateOf() }
instead of
by State {}
by MutableState {}
?allan.conda
12/01/2020, 3:39 PMTristan
12/01/2020, 4:09 PMallan.conda
12/01/2020, 4:10 PMTristan
12/01/2020, 4:11 PMallan.conda
12/01/2020, 4:13 PMval mutableState = remember { mutableStateOf(false) }
mutableState.value = true
var state by remember { mutableStateOf(false) }
state = true