After seeing this post from <@U0PQ0GVLM> I guess I...
# compose
m
After seeing this post from @marcinmoskala I guess I’ve been making this mistake (not accessing a state via a lambda) all over the place. It seems extremely hard to not make this mistake in fact, because it’s not obvious. Any thoughts? https://x.com/marcinmoskala/status/1967861087576985999/photo/1
👀 1
r
I think the use of phrase "everything" is unfortunate in the first example 🙂 There is only one lambda which uses the state, so it is recomposed. But it real apps the layout is more complicated and most of it will not be recomposed.
f
I think it's only relevant for frequently changing values. For example when animating and when the value is passed between multiple layers. Otherwise you don't really need to care about this.
real apps the layout is more complicated
Agreed. Even if you recompose the root element a lot, most of the components inside it will likely be skipped.
Official documentation has dedicated section about this. But the core takeaway should be the very first sentence:
When a performance issue has been identified, deferring state reads can help
👍 2
☝️ 2
m
I also agree that this optimization is only to optimize in cases where we need to improve performance, and we should do it when we test performance. I need to update this post to make it more clear.
👍 1