Apologies - can anyone explain what I need to do t...
# compose-desktop
v
Apologies - can anyone explain what I need to do to fix this message:
Functions which invoke @Composable functions must be marked with the @Composable annotation
- I can't mark
main
as composable; I tried moving the body of my application into a separate @Composable function, but I feel like I'm missing some key understanding here.
c
Compose for Desktop runs inside the normal Java Swing system, currently. the
main
function is literally just the standard entry-point to a JVM application, and there’s nothing specific about it that makes it Composable. You have to bootstrap the Swing/Compose toolkit yourself with the
Window()
function as shown in the “getting started” documentation https://github.com/JetBrains/compose-jb/tree/master/tutorials/Getting_Started
v
Doh! But's remarkable how much code you can write - and have work - without doing this... I've been playing with this for days with my call to `Window()`about 40 lines into the main function!
c
My general debugging process on this is to look up the hierarchy to see if I’m calling something in a non-Composable context. Though I don’t blame you because sometimes it’s not obvious and requires trial-and-error.
And yeah, in the example above
Window
is the root composable in
main