上拉加载更多加载不出来

来源:9-13 上拉加载更多

Jack_WJQ

2021-03-30

一直是正在加载中
图片描述

const mapStateToProps = ({home, loading}: RootState) => ({
  carousels: home.carousels,
  channels: home.channels,
  hasMore: home.pagination.hasMore,
  loading: loading.effects['home/fetchChannels'],
});
onEndReached = () => {
    const {dispatch, loading, hasMore} = this.props;
    console.log(loading, hasMore);
    if (loading || !hasMore) {
      return;
    }
    dispatch({
      type: 'home/fetchChannels',
      payload: {
        loadMore: true,
      },
    });
  };
get footer() {
    const {hasMore, loading, channels} = this.props;
    if (!hasMore) {
      return (
        <View style={styles.end}>
          <Text>--我是有底线的--</Text>
        </View>
      );
    }
    if (loading && hasMore && channels.length > 0) {
      return (
        <View style={styles.loading}>
          <Text>正在加载中...</Text>
        </View>
      );
    }
  }

  get empty() {
    const {loading} = this.props;
    if (loading) {
      return;
    }
    return (
      <View style={styles.empty}>
        <Text>暂无数据</Text>
      </View>
    );
  }

loading一开始是false,但是上拉刷新后就一直为true了,拿到了数据也显示不出

图片描述

写回答

1回答

今朝

2021-03-30

试试给FlatList添加属性

extraData={loading}

如果不行的话,在model里面看看请求是否已返回

0
1
Jack_WJQ
添加属性无效,model请求的数据也返回了。 麻烦老师帮我debug一下,问题找了很久都没找到 https://github.com/avxxfw/Himalaya.git
2021-03-31
共1条回复

跨平台应用ReactNative+TypeScript仿喜马拉雅开发App

从入门到实战,掌握用TypeScript开发ReactNative应用

832 学习 · 339 问题

查看课程