How can I make `currentComposer.recomposeScope` re...
# compose
j
How can I make
currentComposer.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:
Copy code
internal val currentRecomposeScope: RecomposeScopeImpl?
    get() = invalidateStack.let {
        if (childrenComposing == 0 && it.isNotEmpty()) it.peek() else null
    }
Test code:
Copy code
@Composable
private fun Test() {
    val recomposeScope = currentRecomposeScope
    Box(modifier = Modifier.clickable { recomposeScope.invalidate(); println("Invalidate!") })
}
z
Why do you want to make it return null?
j
for test. I just wanted to prove what I understood.