React doesn't allow to use hooks conditionally (di...
# compose
c
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
)
a
yes, it is fine
c
Really? That's one of the big pain points of React for me, really good to know
o
Thanks to the compiler plugin I suppose.
a
this remembered object lives while the condition is true, that is completely fine