hi, im using `Hilt` , but when I use navigation to...
# compose
n
hi, im using 
Hilt
 , but when I use navigation to jump to another page, the 
viewModel
 I get from that page is not the same as the 
viewModel
 I get here
m
You need to pass the
NavBackStackEntry
to
hiltViewModel
method as a param and use the VM which is returned
♥️ 1
c
@ms He seems need to create a ViewModel outside of
NavHost
to share each navigation item. But I remember @Ian Lake once told me that it is best not to (but can) do this? 🤯
n
yes, when i launch app, i need to get a
json
data, and save to the
viewModel
, and it will be used when loading to welcomPage
c
yes, when i launch app, i need to get a 
json
 data, and save to the 
viewModel
 , and it will be used when loading to welcomPage
Oops, if you want to do this, I think you can take a look at this thread: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1616425435392400
♥️ 1