Hello 🙂 what’s the best way to access a string resource inside a coroutine scope? Code in a 🧵
Todor Grudev
07/20/2021, 10:48 AM
Example problem
Copy code
Button(onClick = {
coroutineScope.launch {
# here you can't do stringResource cause of
# @Composable invocations can only happen from the context of a @Composable function
snackbarHostState.showSnackbar(stringResource(id = R.string.clicked))
}
}) {
Text(stringResource(id = R.string.click))
}