Using MUI DataGrid to Show Data from Airtable

I am currently utilizing Airtable as a temporary database for some fundamental data, and I want to use Material-UI’s DataGrid to present this information. While I’m able to fetch the data and see it in the console.log, I’m having trouble getting it to display in the DataGrid.
Here’s what I’m working with, including my implementation of MUI DataGrid and the Airtable npm package:

import React, { useEffect, useState } from ‘react’;
import { makeStyles } from ‘@material-ui/styles’;
import { Container } from ‘@material-ui/core’;
import { DataGrid } from ‘@mui/x-data-grid’;
import Airtable from ‘airtable’;
const airtableBase = new Airtable({ apiKey: ‘’ }).base('’);

const useStyles = makeStyles((theme) => ({
container: {
marginTop: ‘10vh’,
},
}), {});
const columns = [
{ field: ‘id’, headerName: ‘ID’, width: 90 },
{ field: ‘institution’, headerName: ‘Institution Name’, width: 150 },
{ field: ‘locality’, headerName: ‘Location’, width: 150 },
{ field: ‘region’, headerName: ‘State’, width: 150 },
];
export default function DataGridComponent() {
const classes = useStyles();
const [dataRows, setDataRows] = useState();

useEffect(() => {
airtableBase(‘Table 1’)
.select({
maxRecords: 3,
view: ‘Grid view’,
})
.eachPage((records, fetchNext) => {
setDataRows(records);
console.log(records);
fetchNext();
});
}, );

return (



Select at least 1 college

{dataRows && (

)}


);
}
I’m also encountering an issue where only the column headers are visible, and no data appears.

I faced a similar issue when I was integrating Airtable data with MUI DataGrid. In my case, the problem was the format of the data retrieved from Airtable not aligning with how the DataGrid expects it. The DataGrid component needs each row’s data to have a unique identifier specifically set with the identifier key, often ‘id’. You might have the ‘id’ property in your columns, but ensure you’re mapping the Airtable data correctly. Each row of the data should be structured as an object with consistent field names, matching your columns’ ‘field’ properties. To resolve this, when you set the state using ‘setDataRows’, try mapping your records and handle any necessary transformation to align with the expected data structure of the DataGrid. This could involve extracting fields from the Airtable records and setting an ‘id’ for each row based on your unique identifier. This adjustment might help get your data displayed appropriately.