[英]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.