I am trying to access my room database viewModel i...
# compose
n
I am trying to access my room database viewModel in a Repo file rather than a Composable, because I want to use some data in my MainViewModel. I am getting a mismatch when trying to access the viewModel. What could I be doing wrong? It works absolutely fine when I call it within a Composable. I'm getting this: "Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public inline fun <reified VM : ViewModel> ComponentActivity.viewModels(noinline factoryProducer: (() → ViewModelProvider.Factory)? = ...): Lazy<TypeVariable(VM)> defined in androidx.activity"
s
You're not in an activity, check out the error message. ComponentActivity.viewModels is the function definition
Just guessing, but you probably want to restructure your dependencies here
n
Ah ok, thanks for this!
I'll try and work it out
🙂
s
No problem 🤙
a
For the future, this is a good question for #android
👍 2
👍🏼 1