how to fix the error : Reading a state that was c...
# compose
p
how to fix the error : Reading a state that was created after the snapshot was taken or in a snapshot that has not yet been applied I am using compose 1.0.0-alpha05 inside view model : val mutableStateKey = mutableStateOf<String>("") fun someMethod(key: String){ CoroutineScope(Dispatchers.IO).launch { mutableStateKey.value = key } } above code gives the error:
java.lang.IllegalStateException: Reading a state that was created after the snapshot was taken or in a snapshot that has not yet been applied
at androidx.compose.runtime.snapshots.SnapshotKt.readError(Snapshot.kt:1530)
at androidx.compose.runtime.snapshots.SnapshotKt.current(Snapshot.kt:1707)
at androidx.compose.runtime.SnapshotMutableState.setValue(MutableState.kt:499)
Thing is, sometimes updating a mutableState variable on backeground like Dispatchers.IO works just fine @Adam Powell