3

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

z.g.y
  • 5,512
  • 4
  • 10
  • 36
uragiristereo
  • 546
  • 1
  • 6
  • 9
  • This issue can be related to Layout Inspector. You should test recomposition by logging inside `SideEffect` or use random colors as in this question. https://stackoverflow.com/questions/70257459/jetpack-compose-smart-recomposition One of my colleagues told me that he has the same problem, recomposition happening for each item on scroll then he tested by changing colors on each recomposition and reported nothing being recomposed unless an item gets out of ViewPort and comes back in – Thracian Sep 21 '22 at 18:10

1 Answers1

1

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") }
user496854
  • 6,461
  • 10
  • 47
  • 84