TypeError:props.results.map不是函数

尝试弄清楚如何使用.map解决错误,但无法确定如何解决。尝试将我的应用程序转换为useState和useEffect,其他部分仍在运行,但是此错误不断弹出。在转换为useState和useEffect之前,该应用程序运行正常。但是转换后,我仍然收到此错误:

TypeError: props.results.map is not a function
EmployeeTables
src/components/EmployeeTables.js:21
  18 |     <th>DOB</th>
  19 |   </tr>
  20 | </thead>
> 21 | <tbody> 
     | ^  22 |   {props.results.map(
  23 |     ({ login, picture, name, phone, email, dob }) => (
  24 |       <tr key={login.uuid}>

这是我的代码。

import React from "react";
import Moment from "react-moment";
import "../style.css";

function EmployeeTables(props) {
      return (
        <table>
          <thead className = "header"
          style = {{
            backgroundColor: props.theme === "green" ? "#5cb85c" : "white",
            textAlign: "center"
          }}>
            <tr>
              <th></th>
              <th onClick={props.sortByName}>Name</th>
              <th>Phone</th>
              <th onClick={props.sortByEmail}>Email</th>
              <th>DOB</th>
            </tr>
          </thead>
          <tbody> 
            {props.results.map(
              ({ login, picture, name, phone, email, dob }) => (
                <tr key={login.uuid}>
                  <td>
                    <img src={picture.thumbnail} alt=''></img>
                  </td>
                  <td>
                    {name.first} {name.last}
                  </td>
                  <td>{phone}</td>
                  <td>{email}</td>
                  <td><Moment format="MM/DD/YYYY">{dob.date}</Moment></td>
                </tr>
              )
            )}
          </tbody>
        </table>
      );
}

export default EmployeeTables;

提供的任何帮助将不胜感激。

评论