race condition with new getItemKey
I have a race condition that I can't reproduce (yet) in a sandbox. so I will try to describe what it looks like:
the result:
I get to a situation where the first items in virtualItems, up to index k, are with prev keys, and the items after k are with new keys.
in my case I get a duplicate key because an item moved from being first in the list to being in a different place.
what I think happens
I get to
suggested solution
empty
how did we get here
this is a long story, but the gist of it:
1. state changes -> after render resizeObserver of item k is fired
2. at the same time state changes again -> changes
the result:
I get to a situation where the first items in virtualItems, up to index k, are with prev keys, and the items after k are with new keys.
in my case I get a duplicate key because an item moved from being first in the list to being in a different place.
what I think happens
I get to
getMeasurements with pendingMeasuredCacheIndexes = [k] and a new getItemKey. it start iterating from k and misses the key updates to the first item in the cache.suggested solution
empty
pendingMeasuredCacheIndexes when getItemKey changes.how did we get here
this is a long story, but the gist of it:
1. state changes -> after render resizeObserver of item k is fired
2. at the same time state changes again -> changes
getItemKey