What is the difference between viewModel() from the architecture components library and hiltViewModel()?

Viewed 106

As far as I can tell when using Jetpack Compose with Hilt there are two ways of creating/accessing a viewModel instance; viewModel() and hiltViewModel(). I can't understand which should be used as they seem to do the same thing. The documentation for viewModel() suggests that it automatically uses the View Model that Hilt constructs with @HiltViewModel. So what exactly is the difference between these two implementations and when should each be used?

0 Answers
Related