Some notes I shared with my team the other day about Compose recompostuons:
• Make sure any state objects you have only contain val and no var. This should be easy since state is supposed to be immutable anyways.
• If you are using an interface as part of your state object, the interface has to be marked with @Stable or @Immutable so compose knows it can be used for smart recomposition
• Currently Lists passed in trigger recomposition even if immutable. I believe there's a ticket for this to be fixed, one possible solution is to create a holder data class for lists that is marked immutable.
• Implementing a lambda inline with a composable such as Header(onClick = { vm.handleclick() }) will cause recomposition. A few workarounds are:
◦ Hoisting up all unnecessary state and click handlers above the screen and passing them down
◦ Creating an anonymous object in a remember{} that holds all your click functions
◦ If your onClick takes no parameters, using method reference like ::onClick