https://kotlinlang.org logo
#compose
Title
# compose
t

Tijs Gobbens

02/26/2021, 7:58 AM
trying out the navigation library I'm passing the NavController to most of my screens, but this seems to break
@Preview
feature, is. there something I could pass into a composable with preview as a NavController?
l

lewis

02/26/2021, 8:00 AM
The stateless Composable could instead accept a function, for example
onNavigate: (String) -> Unit
f

FunkyMuse

02/26/2021, 8:19 AM
You can just add a default value @Composable @Preview fun MyScreen(navController:NavController = rememberNavController){}
i

Ian Lake

02/26/2021, 3:03 PM
We specifically talk about avoiding passing the NavController down directly in the Testing part of the docs: https://developer.android.com/jetpack/compose/navigation#testing
K 1