Composables are stateless by default, which means that they don't hold a value and can be recomposed any time by the system, which results in the value being reset. However, Compose provides a convenient way to avoid this. Composable functions can store an object in memory using the remember composable.
…
2.9. Conclusion
Summary:
Define composable functions.
Create layouts with Compositions.
Create a button with the Button composable.
Import drawable resources.
Display an image with the Image composable.
Make an interactive UI with composables.
Use the remember composable to store objects in a Composition to memory.
Refresh the UI with the mutableStateOf()function to make an observable.