Hi, is there a way to find out what triggered a re...
# compose
f
Hi, is there a way to find out what triggered a recomposition?
r
Not that I'm aware of, but - as far as I'm aware - there is only a limited number of predetermined points where a recomposition can happen at all. Generally anywhere a
LiveData
is used and has its value updated (or a
StateFlow
) or
remember[...]()
is called for a primitive or something else like a coroutine scope. I haven't myself come across other cases so far, which of course is not to say that there aren't many more
One option would be to pass a logger into the Composable I suppose, but to have a tool of some sort would be much nicer. If I come across something like it, I'll let you know, @Francois Morvillier! Very interesting question 🤔. If you find something and would let me know as well, I would appreciate it a lot!
m
You can also use the compiler reports plugin and check the compsables you suspect shouldnt be recomposing. Generally, you find unstable arguments or non skippable composables which is most probably the cause
m
In practice, the easiest solution is usually the most brutal - remove composables until you find the culprit :)