Giter VIP home page Giter VIP logo

Comments (12)

lesvate avatar lesvate commented on May 16, 2024 1

我也是相同的问题,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.

bolan9999 avatar bolan9999 commented on May 16, 2024 1

You must call reloadData after you change the data source.

from react-native-largelist.

bolan9999 avatar bolan9999 commented on May 16, 2024 1

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.

bolan9999 avatar bolan9999 commented on May 16, 2024

star it first

from react-native-largelist.

mytc avatar mytc commented on May 16, 2024

done

from react-native-largelist.

bolan9999 avatar bolan9999 commented on May 16, 2024

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.

lesvate avatar lesvate commented on May 16, 2024

初始时无数据,刷新后调用reloadData()会出错

from react-native-largelist.

lesvate avatar lesvate commented on May 16, 2024

我暂时不在初始时使用LargeList解决

from react-native-largelist.

mytc avatar mytc commented on May 16, 2024

@bolan9999 , how to use reloadData() ? Can you give me an example?

from react-native-largelist.

bolan9999 avatar bolan9999 commented on May 16, 2024

@lesvate 你是什么版本的,照理说1.1.0和github当前版本都不会出这个问题,这个问题已经修复了的

from react-native-largelist.

bolan9999 avatar bolan9999 commented on May 16, 2024

Try new version 1.2.0 please. Fix some bug when reload data.

from react-native-largelist.

bolan9999 avatar bolan9999 commented on May 16, 2024

closed

from react-native-largelist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.