![](/img/trans.png)
[英]React throws error while using map function to render array of objects
[英]React Native render function throws error
這是我的反應原生渲染功能。 如果我把列表視圖它的工作原理。 如果我把 touchablehighlight 它工作。 但是,如果兩者都放它就行不通了。 需要幫忙。
render: function() {
return (
/* ListView wraps ScrollView and so takes on its properties.
With that in mind you can use the ScrollView's contentContainerStyle prop to style the items.*/
<ListView
contentContainerStyle={styles.list}
dataSource={this.state.dataSource}
renderRow={this._renderRow}/>
<TouchableHighlight onPress={() => this._pressRow(rowID)} underlayColor="transparent">
</TouchableHighlight>
);
},
這里有什么問題? 需要兩個組件才能工作。
您不能有 2 個可以返回的標簽。 您應該將其包裝在<View> </View>
標簽中。 通過這種方式,您可以抽象頁面中需要的多個組件。
render: function() {
return (
/* ListView wraps ScrollView and so takes on its properties.
With that in mind you can use the ScrollView's contentContainerStyle prop to style the items.*/
<View>
<ListView
contentContainerStyle={styles.list}
dataSource={this.state.dataSource}
renderRow={this._renderRow}/>
<TouchableHighlight onPress={() => this._pressRow(rowID)} underlayColor="transparent">
</TouchableHighlight>
</View>
);
},
希望能幫助到你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.