I have a MainScreen composable being injected with a viewmModel using hilt.
@Composable
fun MainScreen(
viewModel: MainScreenViewModel = hiltViewModel()
) {}
The problem is that I cannot use this in the preview because will not generate viewModel using hilt
@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
AlbumExpoTheme {
MainScreen()
}
}
how can I go around this so I can use the preview?
Error is:
java.lang.IllegalStateException: ViewModels creation is not supported in Preview