robnik
02/27/2021, 8:06 PMrememberSavable
and savedInstanceState
. Both are mentioned in https://developer.android.com/jetpack/compose/state. They look like they do the same thing.Dominaezzz
02/27/2021, 8:12 PMSimilarly to how we previously removedcomposable and now promote usage likestate { 0 }
we are going to removeremember { mutableStateOf(0) }
composable. You should usesavedInstanceState { 0 }
instead and it will save and restore automatically if the type used inside the MutableState can be stored in the Bundle. If previously you were passing a custom saver object now you need to use a new overload of rememberSaveable which hasrememberSaveable { mutableStateOf(0) }
parameter. The usage will look like this:stateSaver
val holder = rememberSaveable(stateSaver = HolderSaver) { mutableStateOf(Holder(0)) }