Reactjs React Native:将数据附加到mapStateToProps中的Prop

Reactjs React Native:将数据附加到mapStateToProps中的Prop,reactjs,react-native,redux,react-redux,Reactjs,React Native,Redux,React Redux,我有一个名为“数据”的道具,它填充了数据记录,最初是应用程序加载时的状态。我试图做的是根据我在mapDispatchToProps中启动的函数附加到“data”属性 目前的代码如下: class ListScreen extends React.Component { static navigationOptions = { header: null, }; static propTypes = { navigation: PropTypes.object.isRe

我有一个名为“数据”的道具,它填充了数据记录,最初是应用程序加载时的状态。我试图做的是根据我在mapDispatchToProps中启动的函数附加到“data”属性

目前的代码如下:

class ListScreen extends React.Component {
  static navigationOptions = {
    header: null,
  };

  static propTypes = {
    navigation: PropTypes.object.isRequired,
    data: PropType.isRequired,
    nextBatchOfData: PropTypes.func,
  };

  getData = () => {
    this.props.nextBatchOfData({ some, search, params });
  };

  render() {
    const { data } = this.props;

    return (
      <View style={styles.container}>
        <ScrollView>
          <StatusBar barStyle="default" />
          <FlatList
            data={data}
            keyExtractor={({ id }) => `${id}`}
            numColumns={2}
          />
        </ScrollView>
      </View>
    );
  }
}

const mapStateToProps = state => {
  return {
    data: [...dataSelectors.getOfferResults(state)], // Attempting to append to existing state..
  };
};

const mapDispatchToProps = dispatch => ({
  nextBatchOfData: searchParams => dispatch(actions.dataSearch.request(searchParams)),
});

我相信最好的方法是在减速器上


您将有可用的
状态
,因此在那里进行附加将更自然。

我真的不明白您想要实现什么。你为什么不在减缩器中进行追加?@Arthuratot但我对Redux是新手。我已经用我的行动的一部分更新了我的问题,以供您指导。
[combineActions(actions.dataSearch.success, actions.dataSearch.fail)]: (
      state,
      { payload, meta, error }
    ) => {
      const hasResults = payload && !error;
      return {
        ...state,
        isLoading: false,
        error: error && payload.message,
        results: hasResults ? payload : state.results,
      };