-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to access LocalContext
or stringResources
in a Presenter?
#268
Comments
You would have to provide it yourself at the entry point to your composable running within Molecule. Molecule is not Android-specific nor does it have to run in a location where a Context is available. If you have one that you want to make available, you can provide it like a normal composition local at the root of your composition. |
@amitkma did you get this working? Would be great to get an example as part of this thread as probably others will run into it as well. |
The docs for providing composition local values is here: https://developer.android.com/jetpack/compose/compositionlocal#providing-values. If you have a context instance you provide it as |
I tried multiple variations but none of them seem to work as expected. Can you provide an example? |
I forgot the built-in one returns You have to use your own variant that returns the inner lambda value. See https://issuetracker.google.com/issues/271871288 for both the feature request as well as code you can use. |
I am trying to access Context inside a presenter composable using
LocalContext.Current
, But I couldn't make it work. I am getting the following error ->Any advise or workaround it?
The text was updated successfully, but these errors were encountered: