Comments (12)
我也是相同的问题,renderCell看起来好像没调用,不知何故
@bolan9999
export default class Timeline extends React.Component {
constructor(props) {
super(props);
this.state = {
refreshing:false,
data:[]
};
this.onRefresh = this.onRefresh.bind(this);
}
render() {
return (
<LargeList
style={styles.container}
numberOfRowsInSection={() => this.state.data.length}
heightForCell={() => 88}
onRefresh={()=>{
this.onRefresh();
}}
refreshing={this.state.refreshing}
renderCell={this.renderItem.bind(this)}
/>
);
}
onRefresh () {
try {
this.setState({refreshing:true});
let url = 'xxxxxxxxx';
common.fetchAuthed(url)
.then((responseJson)=>{
if(responseJson.length === 0){
this.setState({
refreshing:false,
});
return;
}
this.setState({
data : responseJson,
refreshing:false
});
})
} catch (e) {
console.log('网络错误');
}
}
componentDidMount () {
this.onRefresh().done();
}
renderItem(section: number, row: number) {
console.log('row='+row);
let msg = this.state.data[row];
return (
<View style={{ flex: 1 }}>
<View style={{ flex: 1, flexDirection: "row", alignItems: "center" }}>
<View style={{marginLeft:4}}>
<Text style={{ fontSize: 18 }}>
{msg.name}
</Text>
<Text style={{ fontSize: 14, marginTop: 8 }}>
{msg.distance}
</Text>
</View>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex:1
},
});
from react-native-largelist.
You must call reloadData after you change the data source.
from react-native-largelist.
let largelistRef;
//get ref when render
<LargeList ref={ref=>{
largelistRef=ref;
}}
/>
//call reloadData
largelistRef.reloadData()
There are 4 samples in the source code on github, why don't you read it first?
from react-native-largelist.
star it first
from react-native-largelist.
done
from react-native-largelist.
reloadData()
Reload all datasource globally.
Notice:
If the numberOfSections ,numberOfRowsInSection,heightForSection,heightForCell change, you must use this method to reload.
Do not use this method often, because it is bad performance.
from react-native-largelist.
初始时无数据,刷新后调用reloadData()会出错
from react-native-largelist.
我暂时不在初始时使用LargeList解决
from react-native-largelist.
@bolan9999 , how to use reloadData() ? Can you give me an example?
from react-native-largelist.
@lesvate 你是什么版本的,照理说1.1.0和github当前版本都不会出这个问题,这个问题已经修复了的
from react-native-largelist.
Try new version 1.2.0 please. Fix some bug when reload data.
from react-native-largelist.
closed
from react-native-largelist.
Related Issues (20)
- Can you set the offset to refresh and load, and set the sliding distance to refresh and load?
- Stickyform android scroll laggedly
- 关于 renderFooter 的问题
- renderIndexPath
- Problem Android with RN 0.66.4
- 关于需要返回列表每一行高度的函数 HOT 1
- 能否加个参数 上拉提前加载更多 类似Flatlist的onEndReachedThreshold
- what is "renderSection" for LargeList?
- 有没有暴露Item 曝光的事件和消失的事件 HOT 1
- 瀑布流card 高度不确定矫正问题
- Error with RN Version 0.69.0
- 'data[section].items.length' 错误 HOT 1
- Sticky header support 有例子嘛 HOT 1
- 大佬,WaterfallList在header高度超过屏幕高度的情况,下面是list瀑布流,会偶尔出现瀑布流有数据,却无法往上拖动的情况
- renderIndexpath dynamic height HOT 1
- how to set customs height for section
- Error install package for react version in the latest react native. HOT 2
- endLoading调用报错 HOT 1
- not showing full list. just white space after that HOT 6
- How to achieve the section sticky header effect on Android as well
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-largelist.