Tash
03/23/2021, 3:52 AMState
, and would like to keep track of the first & last item’s State
. For some reason having trouble wrapping my mind around this particular scenario 🧵 ⬇️Tash
03/23/2021, 3:53 AMitems.forEachIndexed { index, item ->
val itemState = rememberItemState(key = item.id, /** etc **/)
// Somehow do this
if (index == items.size - 1) {
lastItemState.value = itemState
} else if (index == 0) {
firstItemState.value = itemState
}
key(item.id) { Item(state = itemState, content = content) }
}
Any insight is much appreciated 🙏🏼Zach Klippenstein (he/him) [MOD]
03/23/2021, 3:56 AMTash
03/23/2021, 3:57 AMBox
to achieve a stackZach Klippenstein (he/him) [MOD]
03/23/2021, 3:57 AMZach Klippenstein (he/him) [MOD]
03/23/2021, 3:58 AMkey
block, that’s what will ensure that an item’s memoized state will move along with the item if the order of the list changesTash
03/23/2021, 3:58 AMTash
03/23/2021, 3:59 AMif/else
in there needs to happen in some type of Effect
block or not 🤔Zach Klippenstein (he/him) [MOD]
03/23/2021, 3:59 AMTash
03/23/2021, 3:59 AMZach Klippenstein (he/him) [MOD]
03/23/2021, 4:00 AMZach Klippenstein (he/him) [MOD]
03/23/2021, 4:00 AMTash
03/23/2021, 4:03 AMMutableState
s, so that should work. I’ll try moving everything into the key
block and keep an eye on state integrity. Thank you loads!