c

    CLOVIS

    1 year ago
    React doesn't allow to use hooks conditionally (differently each render):
    val Component = fc<RProps> {
    if (…)
    useRef() // big no no
    }
    Is that an issue Compose shares? Or is this safe?
    @Composable
    fun Component() {
    if (…)
    val a by remember { … }
    }
    (ignoring that Kotlin doesn't allow a
    val
    declaration in a braceless-
    if
    )
    Andrey Kulikov

    Andrey Kulikov

    1 year ago
    yes, it is fine
    c

    CLOVIS

    1 year ago
    Really? That's one of the big pain points of React for me, really good to know
    Oleg Khotskin

    Oleg Khotskin

    1 year ago
    Thanks to the compiler plugin I suppose.
    Andrey Kulikov

    Andrey Kulikov

    1 year ago
    this remembered object lives while the condition is true, that is completely fine