Luca Nicoletti

    Luca Nicoletti

    3 years ago
    What does this:
    Caused by: java.lang.IllegalStateException: Composition requires an active composition context
    mean? What are the possible causes?
    kioba

    kioba

    3 years ago
    based on the some quick search seems like the composition context is for to contain the Slot Table and it it referenced as a
    root
    . My assumption based on that is you are calling a compose function without a root to be able to attach itself.
    if you comment out the
    SetContent
    function in your activity you can achieve the same result:
    //setContent {
            epicContent()
    //}
    r

    Ryan Mentley

    3 years ago
    It sounds like you're calling a composable function outside of a composable function - it's like suspend, they can only be called from other composables
    Luca Nicoletti

    Luca Nicoletti

    3 years ago
    Trying to debug it, I have a breakpoint inside every
    @Composable
    function I have, it crashed before even reaching any breakpoints 😒
    r

    Ryan Mentley

    3 years ago
    what's the stack trace?
    Luca Nicoletti

    Luca Nicoletti

    3 years ago
    Found out what was the problem 🙂
    Was using some composable functions (
    +state
    ) to assign values to
    val
    , outside of a
    @composable
    function
    kioba

    kioba

    3 years ago
    Can we actually fail the compilation process if a compose function is called in a none compose function? something like:
    fun a() {
      val a = +state{}
    }
    Luca Nicoletti

    Luca Nicoletti

    3 years ago
    Not only in function though
    You could declare them as I did in a class
    Chuck Jazdzewski [G]

    Chuck Jazdzewski [G]

    3 years ago
    @kioba That is the plan. We plan make effects
    @Composable
    functions that return values. When that is done they will be reported as errors just as trying to call an
    @Composable
    outside and
    @Composable
    is an error.