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

nglauber

07/14/2020, 5:59 PM
Dumb question of the day: Do I have to do something special to see the preview of my composable in the documentation? I mean this:
Copy code
/**
 * My Component
 *
 * @sample com.example.tempcompose.SimplePreview
 */
@Composable
fun MyComposable() { ... }

@Preview
@Composable
fun SimplePreview() {
    MyComposable()
}
When I hit Cmd+Space I can see the sample code, but not the preview…
v

Vinay Gaba

07/14/2020, 6:09 PM
the only requirement is that you need to build it in order to see the Preview. It’s known to be a bit flaky though so could be one of those situations.
n

nglauber

07/14/2020, 6:11 PM
I see… I build and rebuild the project a few times but this feature never worked for me… Is there any setting to enable that or something like that?
b

Brett Best

07/14/2020, 6:18 PM
I’ve noticed that if the first element in my composable is a Scaffold it doesn’t work
n

nglauber

07/14/2020, 6:20 PM
It does not work for me at all 😕 This
MyComposable
function has just one
Text
in it 😞
g

Gabriel Feo

07/14/2020, 8:10 PM
Can you share what’s inside MyComposable exactly?
n

nglauber

07/14/2020, 8:14 PM
@Gabriel Feo does it matter? It’s only a
Text
with some modifiers…
g

Gabriel Feo

07/14/2020, 8:35 PM
Maybe not, but since we couldn’t help you with the other snippet
m

Madhava

07/15/2020, 12:18 AM
Also make sure if your composable has parameters that they have defaults, that was an issue I had.
n

nglauber

07/15/2020, 1:03 PM
@Gabriel Feo @Madhava here is the full code https://gist.github.com/nglauber/a4db90c27a4e3f81b39d130a6c363c73 As I told you, it is just a
Text
with no parameters.
a

allan.conda

07/22/2020, 9:35 AM
which compose and AS version you use? try updating
See if you can see previews from other samples
n

nglauber

07/22/2020, 8:55 PM
Last time I tried was dev-14 on Android 4.2 Canary 4