marcinmoskala
12/03/2024, 9:16 AMChatTopBar gets recomposed unnecessarily because List is not stable, and I can see in Layout Inspector that it gets recomposed, but this print is only executed during the initial composition phase. Do you know what might be the reason why it works this way? I can provide a complete example.
@Composable
fun ChatTopBar(messages: List<Message>) {
println("ChatTopBar recomposition")
TopAppBar(title = {
println("TopAppBar title recomposition")
Text("Messages ${messages.size}")
})
}Stylianos Gakis
12/03/2024, 9:18 AMmarcinmoskala
12/03/2024, 9:23 AMChatTopBar gets recomposed, it should execute its body, so execute print, or am I wrong?Stylianos Gakis
12/03/2024, 9:25 AMprintln("ChatTopBar recomposition") and println("TopAppBar title recomposition") live in different recomposition scopes, provided TopAppBar is not inlinemarcinmoskala
12/03/2024, 9:25 AMChatTopBar should get recomposed due to List not being stable (it hasn't changed, but it is unstable, so it should trigger recomposition), and I can see that it gets recomposed in Layout Manager, but print does not seem to be called.marcinmoskala
12/03/2024, 9:26 AMStylianos Gakis
12/03/2024, 9:26 AMmarcinmoskala
12/03/2024, 9:27 AMStylianos Gakis
12/03/2024, 9:27 AMmarcinmoskala
12/03/2024, 9:27 AMmarcinmoskala
12/03/2024, 9:27 AMmarcinmoskala
12/03/2024, 9:29 AMmarcinmoskala
12/03/2024, 9:34 AMStylianos Gakis
12/03/2024, 9:40 AMPablichjenkov
12/03/2024, 4:47 PMshikasd
12/03/2024, 11:26 PM