在listView中,设置状态后renderRow未调用

在listView中,设置状态后renderRow未调用,listview,react-native,react-native-listview,Listview,React Native,React Native Listview,在列表视图中,当单击renderRow中显示勾号的listview数据时,我这样写 constructor(props){ super(props); var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}); this.state={ dataSource: ds.cloneWithRows(['row 1', 'row 2']) } } compone

在列表视图中,当单击renderRow中显示勾号的listview数据时,我这样写

constructor(props){
    super(props);
    var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
    this.state={
     dataSource: ds.cloneWithRows(['row 1', 'row 2'])
    }
  }
 componentDidMount(){
   //After getting data from service i am setting data to the dataSource
 this.setState({ dataSource: ds.cloneWithRows(responseData.data.listTeamBySportId) })
 }

    onTeam(rowData,rowID){
        if(this.state.opacity == rowID){
          this.setState({opacity:null})
        }else{
          this.setState({opacity:rowID})
        }
      }
    render(){
     <ListView
                       style={{flex:1}}
                      dataSource={this.state.dataSource}
                      renderRow={this.renderData.bind(this)}  
                      renderSeparator={(sectionID, rowID) => <View key=       {`${sectionID}-${rowID}`} style={styles.separator} />}
                      automaticallyAdjustContentInsets={false}/>
    }
    renderData(rowData,sectionID:number,rowID:number){
            return (
              <View style={styles.subBody}>
                <TouchableHighlight onPress={this.onTeam.bind(this,rowData,rowID)}>
                  <View  style={{backgroundColor:rowData.colorCode,height:44,flexDirection:'row'}}>
                     <View style={styles.centersubBody}>
                        <Text style={{color:'white',fontWeight:'bold',fontSize:17,fontFamily:'Roboto-Medium',marginLeft:10}}>{rowData.location}</Text> 
                     </View>
                    <View style={styles.rightsubBody}>
                        {this.state.opacity == parseInt(rowID) ? (
                        <Image style={{marginRight:5,marginTop:5, width:25, height:25, marginBottom:10}} source={require('image!selected')}/>
                        ):<View></View>}
                   </View>
                  </View>
                </TouchableHighlight>
              </View>
        );
       } 
构造函数(道具){
超级(道具);
var ds=新的ListView.DataSource({rowHasChanged:(r1,r2)=>r1!==r2});
这个州={
数据源:ds.cloneWithRows(['row1','row2'])
}
}
componentDidMount(){
//从服务获取数据后,我将数据设置到数据源
this.setState({dataSource:ds.cloneWithRows(responseData.data.ListTeamByPortId)})
}
onTeam(行数据,行ID){
if(this.state.opacity==rowID){
this.setState({opacity:null})
}否则{
this.setState({opacity:rowID})
}
}
render(){
}
automaticallyAdjustContentInsets={false}/>
}
renderData(行数据,节ID:number,行ID:number){
返回(
{rowData.location}
{this.state.opacity==parseInt(rowID)(
):}
);
} 
我的react原生版本是:0.51.0
这里的问题是当数据超过10条记录时,我的代码在OnTeam函数中设置state之后工作,它会再次渲染到renderRow()并显示勾号,但问题是当数据超过10条记录时,它不会转到renderRow数据,请给我一些建议,如何解决它,我非常感谢任何帮助,
listView
组件是特殊的。listView.dataSource有一个api

var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
  dataSource: ds.cloneWithRows(['row 1', 'row 2']),
};

在我看来,如果您不使用ds.cloneWithRows,数据不会更改

如果您希望重新呈现列表,则必须更改状态中的数据 在组件构造函数上,定义保存datasource对象的this.ds变量,并将用于列表数据的变量置于状态。 例如,初始值是

this.state ={
myDs: this.ds.cloneWithRows([])
} 
当你想用新的数据写入重新加载时

this.setState({myDs: this.ds.clone...(arrNewData)};

Uope您理解这个想法

this.setState({dataSource:ds.cloneWithRows(responseData.data.listTeamBySportId)});当我在获取数据后这样写时,数据没有显示在listView中,我可以知道原因吗?你能回答吗?请回答吗?你能给我看一下你的代码吗
this.setState({dataSource:ds.cloneWithRows(responseData.data.ListTeamByPortId)}),我看不到任何问题。您好,我更改了上面的代码,请查看并让我知道MyDealReady是否有任何问题。我这样做了,请查看我更新的上面的代码。我面临相同的问题,我的代码与您的代码相同。你有什么解决办法吗?那么请与我分享。谢谢谢洛,你有解决办法吗?