提供给`AccountList`的类型`object`的prop`comcount`无效,期望一个数组

时间:2017-01-09 15:32:03

标签: redux action

我在我的文件中导入了一个json文件,我创建了一个这样的动作:

import jsonData from './data/account_list_response.json';
const inAccountsList = () => {
    store.dispatch({
      type: 'ACCOUNT_LIST',
      state: {
        accounts: jsonData
      }
    });
};

然后,我在帐户列表容器中将帐户设为prop,如下所示:

function mapStateToProps(state) {
  return { accounts: state.get('accounts').map(account => account.toJS()) };
}

最后

const AccountList = ({ accounts }) => (
  <div className="account-list">
    <h4 className="table-header">Accounts</h4>
    <Table hover>
      <thead>
        <tr>
          <th>#</th>
          <th>Account Number</th>
          <th>Description</th>
          <th>Balance</th>
          <th>Available Balance</th>
          <th>Currency</th>
        </tr>
      </thead>
      <tbody>
        {accounts.map((account, i) =>
          <AccountEntry
            key={account.id} idx={i + 1}
            {...account}
          />
      )}
      </tbody>
    </Table>
  </div>
);

发生错误提供给accounts的类型object的无效道具AccountList,预期是一个数组。为什么???

0 个答案:

没有答案
相关问题