Hi I have a screen with multiple composables, I am...
# compose-android
j
Hi I have a screen with multiple composables, I am updating value of a text upon click of a button in the same screen The structure of my screen looks like this
Copy code
Column
-- Column
-- Text ( static )
-- Button ( onClick of this )
-- Text ( value change onClick of above button )
I am listening to drawWithContent of all composables above Question : During onClick of button, recomposition happens for the 2nd text whose value changes • But drawWithContent gets called for all composables mentioned above I wanted to understand why does drawWithContent of all composables get called when only the 2nd text is expected to recompose and redraw?
s
They are all inside the same recomposition scope, so it makes sense that all of them will try to recompose, no?
j
Got it 1 specific observation I saw was the following -
Copy code
Column ( re-renders )
-- Column ( does not re-render )
-- Text ( re-renders )
-- Button ( re-renders )
-- Text ( re-renders )
re-render here means -> drawWithContent was triggered for that composable Any idea on why the inner column's drawWithContent is not called?
s
No, I am afraid I can't deduce what is going on in such an abstract manner. It may just be that you somehow had introduced a new recomposition scope in there which managed to skip because it realized it could do that. This https://blog.zachklipp.com/scoped-recomposition-in-jetpack-compose-what-happens-when-state-changes/ goes into details about this topic
j
This is helpful ! this blog helps in giving a good direction and I will debug it further Thank you @Stylianos Gakis
a
You also need to keep in mind the fact that Column/Row and Box do not provide a scope. They are rather inlined.