Trying to remove a view index above child count error

What does this mean? This happens when I update a list of iterated views something like

<View style={{ flexDirection: 'row', padding: 20, backgroundColor: '#fff' }}>
  <Ionicons name={jobIcon} color={theme.iconColor} size={30} />
  <Text>{jobService}</Text>
  <Text>{jobDate}</Text>
</View>

mapped inside a scrollview.

this error pops up when I modify the array from child scene. scene1 - is where the ScrollView with job list array of views sence2 - is where I delete a job and should update scene1 when I do remove a job

在这里输入图像描述


In my case I was using LayoutAnimation for my ScrollView. Inside it a map of Items. When an Item is removed from the list this happens. Not using LayoutAnimation seems to be working fine.


This happens when a component only has x amount of children, but you are trying to remove a child with index greater than x. Like an index out of bounds exception that is common with arrays. Can cause lots of frustration because often times the child you are trying to remove DOES INFACT EXIST. But might be happening because you are using a third party component that only expects a certain amount of children.

For me, it happened when I put an extra child into air-bnb MapView. I fixed the issue by making this element the child of it's grandparent (it was absolutely positioned so it didn't affect styling).


It's happening when you call layout animation when it already in process. iOS will show an warning while Android will explode with this error. You can use this easy pattern to fix it when you're using LayoutAnimation from same component.

layoutAnimation()  {
  if (!this.layoutAnimationActive) {
    this.layoutAnimationActive = true;
    LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInOut, () => { this.layoutAnimationActive = false; });
  }
}
链接地址: http://www.djcxy.com/p/94746.html

上一篇: 在ClickOnce中维护程序集版本?

下一篇: 尝试删除子视图错误以上的视图索引