When creating a screen that receives a class as pa...
# compose
p
When creating a screen that receives a class as parameter, which is the recommended way to keep that class in the uistate of the viewmodel? I know that I can do it using a LaunchedEffect and a vm.setCustomClass() inside, but seems to be a bad practice.
Copy code
@Composable
fun DetailsScreen(
    modifier: Modifier = Modifier,
    customClass: CustomClass,
    vm: DetailsScreenViewModel = koinViewModel()
) {
In my vm I have this uiState which should store that customClass variable:
Copy code
data class DetailsScreenUiState(
    val loading: Boolean = false,
    val customClass: CustomClass? = null //this should keep the variable received in the screen parameter
)
t
I also did it like you described. Not sure if it is bad practice. I think it depends how you are using it.