Javascript 反应本机渲染函数引发错误
这是我的react native的渲染函数。如果我使用listview,它会工作。如果我把touchablehighlight放进去,它就会工作。但是,如果它把两者都放在一起,它就不起作用了。我需要帮助Javascript 反应本机渲染函数引发错误,javascript,android,react-native,Javascript,Android,React Native,这是我的react native的渲染函数。如果我使用listview,它会工作。如果我把touchablehighlight放进去,它就会工作。但是,如果它把两者都放在一起,它就不起作用了。我需要帮助 render: function() { return ( /* ListView wraps ScrollView and so takes on its properties. With that in mind you can use the Scroll
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>
);
},
render:function(){
返回(
/*ListView包装了ScrollView,因此具有它的属性。
考虑到这一点,您可以使用ScrollView的contentContainerStyle道具来设置项目的样式*/
这是。\按ROW(rowID)}underlayColor=“transparent”>
);
},
这里怎么了?需要两个组件才能工作。您不能有两个可以返回的标记。您应该将其包装在
标记中。通过这种方式,您可以在页面中抽象出所需的多个组件
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>
);
},
render:function(){
返回(
/*ListView包装了ScrollView,因此具有它的属性。
考虑到这一点,您可以使用ScrollView的contentContainerStyle道具来设置项目的样式*/
这是。\按ROW(rowID)}underlayColor=“transparent”>
);
},
希望有帮助。如果我必须通过道具,我也可以使用view吗?是的,view是一个组件。您完全可以使用ListView执行任何操作。我的意思是,所有react本机组件中的共同点也可以在上使用。