What's the pattern to pass state up the component ...
# compose
d
What's the pattern to pass state up the component tree? Use case: I have some deep child scrollable component, and I want to display a scroll position in the parent. I guess I should pass the mutable state down to this component and observe it in the parent, correct?
👌 2
h
yes, that's one right way to do it. If I'm not mistaken
ScrollableColumn
does exactly what you described.
👆 1
d
great, thanks!
d
You also can pass a lambda that updates it
Copy code
MyChild(onScroll = { scrollPosition.value = it })

fun MyChild(onScroll: (Int) -> Unit)
âž• 1
d
oh, right, that's even simpler.