Unnecessary recomposition happening on IconButton

Viewed 36

I have this simple IconButton, but when i try to inspect the recomposition the number goes up when scrolling on LazyColumn, whereas the IconButton is unaffected. I've tried to pass empty lambda on the onClick, no recomposition happened though.

IconButton(
    onClick = onBackArrowClick,
    content = {
        Icon(
            imageVector = Icons.Default.ArrowBack,
            contentDescription = null,
        ),
    }
)

enter image description here

1 Answers

Well, it obviously looks like something is happening with your onBackArrowClick labmda that's causing it to recompose. Try passing a non-variable labmda, and see what happens. Something like:

onClick = { Log.d("***", "OnClick triggered") }
Related