Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
How to change API data which is in object type to array?

ERROR: Failed prop type: Invalid prop rows of type object supplied to ForwardRef, expected an array.

Here is my code...

import React,{useState,useEffect}  from "react";
import { DataGrid } from '@mui/x-data-grid';

const columns=[
    {field:'_id', headerName:'ID'},
    {field:'firstName',headerName:"FirstName", width:300},
    {field:'lastName',headerName:"LastName", width:600},
    {field:'email', headerName:"Email", width:700}
]





const DataTable=()=>{
 
    const[tableData,setTableData]=useState([])

    useEffect(()=>{
        fetch('http://127.0.0.1:3333/entry')
        .then((data)=>data.json())
        .then((data)=>setTableData(data))
    },[])
   
console.log(tableData);


    return(
        <div  style={{height:600, width:'99%'}}> 
            <h1>Data Table</h1>
            <DataGrid  getRowId={(r) => r._id} rows={tableData} columns={columns}  checkboxSelection/>
            </div>
    )
}

export default DataTable
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!