Join Slack
Powered by
how does one integrate android view models with co...
# android
u
0xf1f1
02/06/2024, 5:24 PM
how does one integrate android view models with compose @preview() ?
j
jefbit
02/06/2024, 5:27 PM
You shouldn't use your viewmodel within your composable preview.
jefbit
02/06/2024, 5:27 PM
Take a look at this resource here
https://developer.android.com/jetpack/compose/tooling/previews#preview-viewmodel
✅ 1
👍 2
u
0xf1f1
02/06/2024, 6:04 PM
So it is better to pass data instead of the view model to a screen - that way you can feed sample data to the preview composite
j
jefbit
02/06/2024, 6:05 PM
Correct, also makes it easier to reuse that composable component in other areas.
✅ 2
u
0xf1f1
02/06/2024, 6:05 PM
thanks jeff
👍 1
12
Views
Open in Slack
Previous
Next