试图使框架超出范围

时间:2018-09-06 16:23:36

标签: react-native redux react-native-flatlist

我正在使用Flatlist和Redux加载一些花朵列表。 现在,当我尝试将数据添加到列表时,出现了以上错误消息。

我认为reducer存在一些问题,但是我已经尝试了很多解决方案。

Here is my response

  render() {
const flowers = this.props.flowers ? this.props.flowers.results : [];
console.log('flowers in renderu', flowers);
return (
  <View style={styles.container}>
    <SearchBar searchFlowers={this.searchFlowers} />
    <FlatList
      keyExtractor={(item, index) => index.toString()}
      renderItem={this.renderFlower}
      onRefresh={this.getFlowers}
      data={flowers}
      numColumns={2}
      refreshing={false}
    />
  </View>
);

}

这是我的减速机:

    import * as types from './types';

const INITIAL_STATE = {
  isFetching: false,
  results: [],
};

export default function reducer(state = INITIAL_STATE, action) {
  switch (action.type) {
    case types.GET_FLOWERS:
      return { ...state, loading: true, results: []};
    case types.GET_FLOWERS_SUCCESS:
      return { ...state, loading: false, results: action.payload };
    case types.GET_FLOWERS_FAIL:
      return {
        ...state,
        loading: false,
        error: 'Error while fetching flowers'
      };
    default:
      return state;
  }
}

0 个答案:

没有答案