Uncaught TypeError: Cannot read properties of undefined (reading 'flatMap') while using react-table

41 Views Asked by At

I am using react table to create the data grid table but it giving me the Cannot read properties of undefined error

import { getCoreRowModel, useReactTable } from "@tanstack/react-table";
import axios from "axios";
import React, { useEffect, useState } from "react";
import { COLUMNS } from "./constants/column";

function Table() {
  const [data, setData] = useState([]);
  const fetchData = async () => {
    const { data } = await axios.get(
      "https://jsonplaceholder.typicode.com/users"
    );
    setData(data);
  };

  useEffect(() => {
    fetchData();
  }, []);

  const table = useReactTable({
    COLUMNS,
    data,
    getCoreRowModel: getCoreRowModel(),
  });

  const { getHeaderGroups } = table;

  console.log("table", getHeaderGroups());

  return <div>aaaaaaaaa</div>;
}

export default Table;

above is the code that i am trying to do it's give error in the console.log

0

There are 0 best solutions below