Junior — Senior
Error detection on a screen implemented with Jetpack Compose
livecode
Task condition
Task: analyze the code of a screen written in Jetpack Compose and identify potential issues in its implementation.
@Composable
fun MyScreen() {
val screenViewModel = remember { MyViewModel() }
val uiState by screenViewModel.state.collectAsState()
MyComposableItem(
name = uiState.name,
onButtonClick = { screenViewModel.onAction() }
)
}
In this example, a ViewModel is created, state is collected via collectAsState, and the obtained data is passed to a child composable. It is necessary to identify what shortcomings might be present in such an approach (e.g., improper ViewModel lifecycle management, lack of error handling, inefficient recompositions, etc.).