0
我在React Native中製作ListView並獲取「無法將類作爲函數調用」錯誤。我還嘗試在課前添加「新」關鍵字,但仍然沒有解決錯誤。以下是我的代碼:無法在React Native中將類作爲函數錯誤調用
import React, {Component} from 'react';
import {StyleSheet, View, AppRegistry, ListView, Text} from 'react-native';
class listview extends Component{
constructor(props){
super(props);
var ds = ListView.DataSource({rowHasChanged : (r1,r2) => r1!==r2});
this.state = {
dataSource: ds.cloneWithRows(['1','2','3','4'])
}
}
_renderRow(rowData){
return <Text>{rowData}</Text>;
}
render(){
return(
<ListView
dataSource = {this.state.dataSource}
renderRow = {this._renderRow.bind(this)}
/>
);
}
}
AppRegistry.registerComponent('listview',() => listview);
您可以看到錯誤here。我如何解決它?