warning.js?8a56:35 警告:失败的道具类型:无效的道具使用 redux-saga

warning.js?8a56:35 Warning: Failed prop type: Invalid prop use redux-saga

每当我向编辑器发出任何操作时都会出现此错误。

warning.js?8a56:35 Warning: Failed prop type: Invalid prop `forumCard` of type `object` supplied to `ForumCard`, expected `array`.
    in ForumCard (created by Connect(ForumCard))
    in Connect(ForumCard) (created by RouterContext)
    in div (created by View)
    in View (created by Navigation)
    in div (created by View)
    in View (created by Navigation)
    in MuiThemeProvider (created by Navigation)
    in Navigation (created by WithWidth)
    in EventListener (created by WithWidth)
    in WithWidth (created by Connect(WithWidth))
    in Connect(WithWidth) (created by Authentication)
    in Authentication (created by Connect(Authentication))
    in Connect(Authentication) (created by RouterContext)
    in RouterContext (created by Router)
    in Router
    in Provider

这是我的组件

import React, {Component, PropTypes} from 'react';
import autobind from 'class-autobind';
import {Table, Row, Cell} from 'react-responsive-table';
import {Link} from 'react-router';

import View from '../components/View';

import styles from './ForumCard-style';

export default class ForumCard extends Component {

  constructor() {
    super(...arguments);
    autobind(this);
    this.state = {
      dateUpdateTopic: new Date(),
      forumCardErrorAlertIsShown: false,
    };
  }

  componentWillMount() {
    this.props.onFetchForumCard();
  }

  render() {
    return (
      <View>
        <Table style={styles.padding} material>
          <Row header key="row1">
            <Cell key="cell1"><Link to="/forum/topic-detail">Topik</Link></Cell>
            <Cell key="cell2">Penulis</Cell>
            <Cell key="cell3">Komentar</Cell>
            <Cell key="cell4">Favorit</Cell>
          </Row>
        </Table>
      </View>
    );
  }
    }

ForumCard.propTypes = {
  onFetchForumCard: PropTypes.func,
  forumCard: PropTypes.array,
};

这是我的容器

import {connect} from 'react-redux';

import ForumCard from '../components/ForumCard';

export function mapStateToProps(state) {
  let {forumCard} = state;
  return {
    forumCard,
  };
}

export function mapDispatchToProps(dispatch) {
  return {
    onFetchForumCard() {
      dispatch({type: 'FETCH_FORUM_CARD_REQUESTED'});
    },
  };
}

export default connect(mapStateToProps, mapDispatchToProps)(ForumCard);

您已将 forumCardpropType 指定为数组,而其类型即将成为 object。确保 forumCardarray。或者,如果您希望它是一个对象,请将 propType 更改为 Object

ForumCard.propTypes = {
  onFetchForumCard: PropTypes.func,
  forumCard: PropTypes.object,
};