# compose


11/13/2023, 2:59 PM
Hello! Can someone explain to me why recomposition count in layout inspector is changing while my composable function is not run?
A very basic example will be something like that: My state class:
Copy code
data class State(
    val text: String,
    val onClick: () -> Unit
My view model:
Copy code
class ViewModelX : ViewModel() {
    private val _stateFlow: MutableStateFlow<State> = MutableStateFlow(State(text = "Hello, world1", onClick = ::updateStateReference))
    val stateFlow: StateFlow<State> = _stateFlow

    private fun updateStateReference() = viewModelScope.launch {
My view:
Copy code
// ... in MainActivity.kt
        setContent {
            val state by viewModelX.stateFlow.collectAsState()
// ...

fun Screen(state: State) {
    MyButton(text = state.text, onClick = state.onClick)

fun MyButton(text: String, onClick: () -> Unit) {
    Button(onClick) {
        Text(text = text)
Now every time i press button the recomposition count in layout inspector for Button goes up. But when I attach debugger it never runs into breakpoint that i set on Button composable 🤷