很长一段时间以来,我一直在努力解决这个问题.
我已经查看了StackOverflow和解决方案的其他问题,但我找不到清楚的问题.
我知道我可以在完全重新渲染前添加,但我不知道如何在没有完全重新渲染的情况下进行前置.
当我将数据上传到ListView时,我想我可以使用非索引键来实现这一点,但我不确切地知道如何或在何处分配非索引键.(非索引意味着ListView用于比较旧行和新行的键不仅仅依赖于数据源数组的索引)
所以这些是我的问题.
如何分配非索引键?
如果我成功分配非索引键,那么我是否能够在两种情况下都不能重新渲染所有行的BOTH可加装AND可附加ListView?
如果没有,那你怎么解决这个问题?因为这似乎是一个非常常见的问题,我很惊讶ListView还没有这个功能.
*另外,我在GitHub上查看了PrependableListView,但它看起来像是ListViewDataSource的精确副本.我错过了什么?如果我在PrependableListView中遗漏了一些东西,那么有人可以指出哪里?
为了帮助理解我的问题,下面是我正在使用的测试代码.
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
ListView,
RefreshControl,
View
} from 'react-native';
export default class Test1 extends Component {
constructor(props){
super(props);
const arr = [];
this.state = {
dataSource: new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}),
refreshing: false,
};
}
componentWillMount(){
this.arr = [];
for(let i = 0; i < 16; i++){ …Run Code Online (Sandbox Code Playgroud)