Javascript 使用flatlist对本地redux进行反应,以便在本地屏幕上进行无限滚动

Javascript 使用flatlist对本地redux进行反应,以便在本地屏幕上进行无限滚动,javascript,react-native,redux,Javascript,React Native,Redux,我的api不提供使用页面获取的页面。在本例中,我也使用redux,目前我将结果分成10行,并使用flatlist仅显示10个结果 我计划用redux做的是,在onEndReached结束时调用action函数,将LOAD_更多地传递给reducer,并与我当前状态的另外10条记录合并,然后再次传递回我的组件 但我不知道我该怎么做,在OneDreached上 这是我为我的组件准备的 render() { if (this.props.loading) { retur

我的api不提供使用页面获取的页面。在本例中,我也使用redux,目前我将结果分成10行,并使用flatlist仅显示10个结果

我计划用redux做的是,在onEndReached结束时调用action函数,将LOAD_更多地传递给reducer,并与我当前状态的另外10条记录合并,然后再次传递回我的组件

但我不知道我该怎么做,在OneDreached上

这是我为我的组件准备的

 render() {
       if (this.props.loading) {
        return (
            <View style={styles.activityIndicatorContainer}>
            <ActivityIndicator animating={true}/>
            </View>
            );
    } else {
        return (

          <Container style={{flex: 1}}>
          <Content>
          <FlatList
          ref='listRef'
          data={this.props.currData}
          renderItem={this.renderItem}
          keyExtractor={(item, index) => item.sno+item.name+item.cid}
          onEndReached={this.handleMore}
          onEndReachedThreshold={0}
          />
          </Content>
          </Container>

          );
    }
}
handleMore = () => {
    this.props.loadMore();
};
// The function takes data from the app current state,
// and insert/links it into the props of our component.
// This function makes Redux know that this component needs to be passed a piece of the state
function mapStateToProps(state, props) {
    return {
        loading: state.dataReducer.loading,
        data: state.dataReducer.data,
        currData: state.dataReducer.currViewData
    }
}

// Doing this merges our actions into the component’s props,
// while wrapping them in dispatch() so that they immediately dispatch an Action.
// Just by doing this, we will have access to the actions defined in out actions file (action/home.js)
function mapDispatchToProps(dispatch) {
    return bindActionCreators(Actions, dispatch);
}
这是一个简单的测试,看看当我滚动到底部时,是否可以在控制台日志中点击LoadMore。看来我打不中了。可能的话,我如何设置这样的东西


我的结果返回有很多数据,我更喜欢一次加载10个,然后向下滚动10个,我唯一的问题是我的api没有页面来支持通常的无限滚动

我相信你的
平面列表中缺少
extraData={this.props}
。如READ文档中所述。。。“用于通知列表重新呈现的标记属性(因为它实现了PureComponent)。如果任何renderItem、页眉、页脚等函数依赖于数据属性之外的任何内容,请将其粘贴在此处并进行不变的处理。”将此添加到我的平面列表中,当我在屏幕滚动的底部时,我的函数仍然无法加载。无法启动或触发ONEDREACHED,并且将阈值设置为大于0将导致在我的页面准备就绪时自动加载,而不是将其滚动到底以便加载任何解决方案?在redux中是否在Flatlist中具有无限滚动。如果它有Flatlist无限滚动,有没有人对此提供任何参考
export function loadMore(){
    return (dispatch) => {
        console.log("load more");
        //dispatch({type: LOAD_MORE, data: test});
    };
}