In a Kotlin React project there are two major opti...
# javascript
m
In a Kotlin React project there are two major options to pass data from parent to ancestors: 1) via
RProps
2) via
StateFlow
There efficiency however is quite different I think: 1) When
RProps
change in a parent, the entire parent and all of its ancestors are re-rendered. 2) When
StateFlow
emits new state, only ancestors that collect that
StateFlow
into local state are re-rendered. So 2) should be way more efficient in theory. Is that correct? OTOH you can use
memo()
for 1). It just potentially causes more potentially expensive equality checks. And
memo
breaks when passing callbacks as props, doesn’t it?