Summary
This chapter aimed to provide a more detailed look at state in Compose apps. We started by exploring the differences between stateful and stateless composable functions. You learned their typical use cases and why you should try to keep your composables stateless. Hoisting state is a tool to achieve that. We covered this important topic in the second main section. I also showed you that you can make your composable functions more reusable by passing logic as parameters, rather than implementing it inside the composable. The previous section explored the integration of a Compose UI hierarchy in activities related to how to retain user input. We looked at the differences between remember {}
and rememberSaveable {}
, and I gave you a glimpse of how bigger Compose apps can benefit from ViewModel
classes.
Chapters 1 to 5 introduced you to various aspects of Jetpack Compose, such as composable functions, state, and layout. Chapter 6, Building a Real-World App, will focus on one...