https://kotlinlang.org logo
Title
v

Vahalaru

02/09/2022, 5:40 PM
Whoa wait a minute... do you not need to make a separate function to preview a composable? Current instruction day to make a composable then another composable annotated with preview. Can you just add preview to a composable?
a

annsofi

02/09/2022, 5:50 PM
A Preview is just another composable so you can probably annotate your “regular” one, but you will be limited in how you set the parameters to that composable.
c

Chris Sinco [G]

02/09/2022, 6:19 PM
Yes, you can annotate any Composable with Preview. Very useful when starting out with small projects and learning Compose.
But over time, we recommend you use it not on the implementations of your Composables but as separate functions that are like small UI tests
Also, you can have multiple Preview annotations on a single Composable function to generate more than one Preview
💯 1
☝️ 1