I am trying to use ```val parentViewModel = hiltNavGraphViewModel<ParentViewModel>("Parent")``...
y
I am trying to use
Copy code
val parentViewModel = hiltNavGraphViewModel<ParentViewModel>("Parent")
but no matter what I do it imports the wrong hiltNavGraphViewModel which takes backStackEntry as a param and does not work in the end. When I type hiltNavGraphViewModel I can see the option for the one that has a String param but even after I select it and Android Studio auto completes the code to
Copy code
hiltNavGraphViewModel(route = )
it is still the one that requires backStackEntry and route is red
i
The one that takes a route is an extension method on
NavController
- you have to do
navController.hiltNavGraphViewModel<ParentViewModel>("Parent")
The
NavController
is how it gets the right
NavBackStackEntry
for the route (using the
navController.getBackStackEntry(route)
method)
You'll want to file an issue against Hilt for the docs issues: https://issuetracker.google.com/issues/new?component=874079
y
Sorry I didnt see this earlier, I should have posted all this in one thread as well.
Thanks, exactly what I found.
I will file a report