Ji Sungbin
05/25/2022, 5:43 PMcurrentComposer.recomposeScope
return null?
recomposeScope
comes from invalidateStack
, and I thought invalidateStack
would be empty when no referencing state inside. But it wasn’t.
currentRecomposeScope code:
internal val currentRecomposeScope: RecomposeScopeImpl?
get() = invalidateStack.let {
if (childrenComposing == 0 && it.isNotEmpty()) it.peek() else null
}
Test code:
@Composable
private fun Test() {
val recomposeScope = currentRecomposeScope
Box(modifier = Modifier.clickable { recomposeScope.invalidate(); println("Invalidate!") })
}
Zach Klippenstein (he/him) [MOD]
05/25/2022, 5:53 PMJi Sungbin
05/25/2022, 5:54 PM