react-native - 在 React-Native 中发生意外错误“index = 8, count = 2”
问题描述
尝试在 MapView 中呈现文本时。我正面临这个错误。
每当我创建一个Text
in 时,RealTimePosition.js
我都会收到 Error index = 8, count = 2
。我不明白为什么会发生此错误以及如何修复它。请帮我解决它。
在 IOS 设备中工作正常
Component where the error is occurring
class RealTimePosition extends Component{
....
return(
<View>
<View>
<Text>
//after removing this View and Text code is working fine but adding the View gives me error.
</Text>
</View>
{
showBus?
<MapView.Marker
coordinate = {realTimeData}
anchor = {{x:0.5, y:0.5}}
flat = {true}
>
<Image
source={require("../../assets/images/schoolBus.png")}
style = {{ width:42, height:42, transform: [{ rotate :
`${rotation}deg`}]}}
/>
</MapView.Marker>:
null
}
</View>
)
}
calling RealTimePosition from this MapAnimateToRegion.js
class MapAnimateToRegion extends Component{
...
return(
<View>
<MapView>
{
CrossButtonvisible?
<RealTimePosition
routeId = {routeId}
polyLinedata = {this.state.pickData}
HomeCoordinate = {this.HomeCoordinate}
onRef={ref => (this.parentReference = ref)}
parentReference = {this.parentMethod.bind(this)}
/>:
null
}
</MapView>
</View>
)
}
parent Component
class Parent extends Component{
....
render(){
if(this.state.currentScreen == "showMap")
{
const {stopsData} = this.state;
const {stopId} = this.state;
const {stopSequence} = this.state;
const {routeId} = this.state;
const {pickData} =this.state
return(
<View style={styles.container}>
<MapAnimateToRegion
stopsData = {stopsData}
stopId = {stopId}
routeId = {routeId}
stopSequence = {stopSequence}
Data = {pickData}
onRef={ref => (this.TimeparentReference = ref)}
TimeparentReference = {this.onTimeChange.bind(this)}
/>
</View>
)
}
解决方案
推荐阅读
- javascript - 更新节点中的对象值
- scope - 如何在 Chrome Dev Tools 的全局范围内设置断点?
- rust - 不能将 `self.blocks` 借为可变的,因为它也被借为不可变的
- java - 负数除法得到的余数
- jquery - 选择选择 - 注入动态选项作为第一个选择选项
- laravel - 验证请求中的数据失败
- javascript - 在 Shopify 网页中创建简单的尺寸转换脚本
- c++ - c++- 数字 100 的阶乘
- flutter - 如何从 inAppWeview Flutter 中的 webVew 按钮操作接收值
- java - 如何在java8中解析像“5th Apr 1920”这样的日期字符串