I have a list of views in a `Column`: `A`, `B`, `C...
# compose
d
I have a list of views in a `Column`:
A
,
B
,
C
If I add a view
D
to the end of the list to make
A
,
B
,
C
,
D
then
D
is merely added and
A
,
B
,
C
are not recomposed. However if I add it to the head of the list
D
,
A
,
B
,
C
then all are recomposed, I do not want this! I tried setting
layoutId
as a hint to Compose/Column that
A
,
B
,
C
remain the same elements, but this didn't work. Is there some mechanism I'm missing?
f
You could try using key ~>
key(id) { A() }
key
is a utility composable that is used to "group" or "key" a block of execution inside of a composition. This is sometimes needed for correctness inside of control-flow that may cause a given composable invocation to execute more than once during composition.
As I understand it, it should tell the runtime that the Node moved instead of that it's input have changed
d
Perfect! It worked. I even knew about
key
just... didn't make the connection to this use case somehow 🤦- thanks for strengthening that synaptic pathway 😁
f
Happens to the best of us 😛 I'm glad it helped