【问题标题】:RenderFooter called infinitely无限调用 RenderFooter
【发布时间】:2019-10-04 18:46:40
【问题描述】:

当我到达 FlipKarts recyclerlistview 的底部时,它进入了一个无限循环调用 renderFooter 数千次,我无法再向上滚动了......不知道这可能是什么。它应该滚动到底部,然后简单地反弹或停留在底部。相反,它卡住了,我在 github 或 stackoverflow 上什么也没找到。

    renderFooter() {
        if(this.state.outPosts == false) {
            return <View style={{
                alignContent:'center', 
                justifyContent:'center', 
                alignItems:'center', 
            }}>
                <ActivityIndicator 
                    style={{
                        marginTop:15*factor_ver,
                        marginBottom:15*factor_ver,
                    }} 
                    size={"small"}
                    color={'#9b9b9b'}
                />
            </View>
        }
        else if(this.state.outPosts == true) {
            return <View style={{
                        height:140*factor_hor, 
                        marginTop:20, 
                        alignContent:'center', 
                        justifyContent:'center', 
                        alignItems:'center', 
                    }}>
                        <Text style={{textAlign:'center', fontSize:22*factor_hor, fontFamily:'Avenir Next', color:'#9b9b9b',}}>
                            No posts! :(
                        </Text>
                        <View style={{flex:1,}}></View>
                        <Block width={60*factor_hor}
                            height={60*factor_hor}
                            style={{
                                justifyContent:'center',
                                alignContent:'center',
                                flex: 1,
                        }}
                        />
                        <View style={{height:30}}></View>
                    </View> 
        }
    }


                    <RecyclerListView 
                        style={{flex:1, backgroundColor:'#f7f7f7', paddingTop:8*factor_hor,}}
                        extendedState={this.state}
                        rowRenderer={this._renderRow} 
                        dataProvider={this.state.dataProvider}
                        layoutProvider={this._layoutProvider}
                        showsVerticalScrollIndicator={false}
                        onEndReached={() => this.fetchPosts()}
                        onEndReachedThreshold={500}
                        renderFooter={this.renderFooter}
                        onScroll={(e) => this.handleScroll(e)}
                        scrollThrottle={250}
                        refreshControl={
                        <RefreshControl
                            tintColor={'white'}
                            refreshing={false}
                            onRefresh={() => { 
                                this.setState({isLoad:true}), this.refresh_feed()}} 
                        />}
                    />

【问题讨论】:

    标签: react-native listview android-recyclerview react-native-flatlist


    【解决方案1】:

    太好了,所以我将把它留在这里,因为我找不到其他任何东西来解释这一点。如果您使用 React 本机 FlipKart recyclerlistview 并且渲染空视图,那么当您滚动到底部时,会发生此故障,您无法向上滚动并且会无限调用 renderFooter。检查以确保每个渲染视图至少有一个容器来填充它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-13
      • 2016-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-09
      • 2010-11-18
      相关资源
      最近更新 更多