79361659

Date: 2025-01-16 13:00:39
Score: 0.5
Natty:
Report link

This is somewhat how your Table.jsx component should look like.

import React, { useEffect, useState } from "react";

export default function Table() {
  const [data, setData] = useState([]);

  useEffect(() => {
    getFakeApiData();
  }, [data]);

  const getFakeApiData = async () => {
    return await fetch("https://jsonplaceholder.typicode.com/users")
      .then((data) => data.json())
      .then((data) => setData(data));
  };

  return (
    <div>
      {data.map((user) => {
        const { name, email, address, company } = user;
        return (
          <tr key={name}>
            <td>{name}</td>
            <td>{email}</td>
            <td>{address.city}</td>
            <td>{company.name}</td>
          </tr>
        );
      })}
    </div>
  );
}

Calling the component inside the App.js

import React from "react";
import Table from "./Components/Table/Table";
import "./styles.css";

const App = () => {
  return (
    <div className="App">
      <Table />
    </div>
  );
};

export default App;

Output of the code

Leanne Graham   [email protected]   Gwenborough Romaguera-Crona
Ervin Howell    [email protected]   Wisokyburgh Deckow-Crist
Clementine Bauch    [email protected]  McKenziehaven   Romaguera-Jacobson
Patricia Lebsack    [email protected]   South Elvis Robel-Corkery
Chelsey Dietrich    [email protected]    Roscoeview  Keebler LLC
Mrs. Dennis Schulist    [email protected] South Christy   Considine-Lockman
Kurtis Weissnat [email protected]  Howemouth   Johns Group
Nicholas Runolfsdottir V    [email protected]    Aliyaview   Abernathy Group
Glenna Reichert [email protected] Bartholomebury  Yost and Sons
Clementina DuBuque  [email protected]  Lebsackbury Hoeger LLC

IMAGE enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: shantanu.singh