简体   繁体   English

使用无状态组件反应渲染失败

[英]react render failed using stateless component

Trying to use stateless component with fetch but failed, the fetch api is working, I'm able to get the data but somehow I see nothing appear in my stateless component 尝试将无状态组件与获取一起使用,但失败了,获取API正常工作,我能够获取数据,但是以某种方式我看不到无状态组件中没有任何内容

import React, { PropTypes } from 'react';
import { Card, CardTitle, CardText } from 'material-ui/Card';
import { map } from 'lodash';

const AdminDashboard = (users) => (
  <Card className="container">
    <CardTitle
      title="Approve applicants"
    />
    {map(users, user =>
        <li key={user._id}>{user.email}</li>
    )}
  </Card>
);

AdminDashboard.propTypes = {
  users: PropTypes.array.isRequired
};

export default AdminDashboard;

My container for admin dashboard is here https://pastebin.com/raw/UtxZLh3a 我的管理仪表盘容器在这里https://pastebin.com/raw/UtxZLh3a

I have no clue why this is not working. 我不知道为什么这不起作用。

Try changing the constructor in AdminDashboardPage to be 尝试将AdminDashboardPageconstructor更改为

constructor(props) {
  super(props);
  this.state = {
    users: [] // <----- array instead of object
  }
}

As a side note, you really should put your li tags inside some ul tags . 附带说明一下, 您确实应该将li标签放在ul标签中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM