ReactJs的“ map”不是函数

时间:2018-10-21 13:11:24

标签: javascript reactjs

我尝试获取Github API以获取用户GitHub信息

  componentDidMount() {
    const { username } = this.props;
    const { clientId, clientSecret, count, sort } = this.state;

    fetch(
      `http://api.github.com/users/${username}/repos?per_page=${count}&sort=${sort}&client_id=${clientId}&client_secret=${clientSecret}`
    )
      .then(res => res.json())
      .then(data => {
        if (this.refs.myRef) {
          this.setState({ repos: data.conves });
        }
      })
      .catch(err => console.log(err));
  }

当我开始使用map()渲染时,我得到一个错误,指出map()无法正常工作!

 const repoItems = repos.map(repo => (
  <div>
    <Link to={repo.html_url} className="text-info" target="_blank">
       {repo.name}
     </Link>
  </div>
 ));

enter image description here

0 个答案:

没有答案