Adding new items to virtual list shows wrong content visually.

When I add new items, the virtual list shows wrong content for the new item. I scrolled down, and then back up to the new item and now it shows the correct content.

How can I make the correct content appear instantly?

Also, when I console.log(segments[virtualItem.index]), I see that there is correct item with the correct data, but visually there is wrong data.

EDIT: Got this working, by adding state:
const [enabled, setEnabled] = useState(true);

And everytime before chaning form state, I set enabled to false.
And then with useEffect I listen to segments, and there I set enabled back to true.

Still wondering, is there a better solution?

My code:
Was this page helpful?