'Bindig issue in react using ant design framework

I am making CRUD application on react Using ant design, i am using axios to get data from nodejs server

Here is the code of Table

 <Table columns={columns} dataSource={dataSource} />

here is the useState where i am saving my data

 const [dataSource,SetDataSource] = useState([])

here is the useEffect for fetching data

 useEffect(() => {

    const load = async () => {
        try {
            const res = await fetch('http://localhost:4000/stock/list')
            const myData = await res.json();
            const check = myData.data;
            console.log(check)
            SetDataSource(check)
            console.log(dataSource)
            // console.log(myData.data)
            // console.log(allItems);
        } catch (error) {
            console.log(error)
        }
    }
    load()
}, []
)

here are columns using in my table

 const columns = [
    {
      title: 'Item Name',
      dataIndex: 'name',
      key: '1',
      render: text => <a>{text}</a>,
    },
    {
      title: 'Category',
      dataIndex: 'Category',
      key: '2',
    },
    {
      title: 'Item Price',
      dataIndex: 'Item_Price',
      key: '3',
    },
    {
      title: 'Item Amount',
      dataIndex: 'Item_Amount',
      key: '4',
    },

    {
      title: 'Action',
      key: '5',
      render: (record) => {
        return(
          <>
          <EditOutlined onClick={()=>{
            onEditItems(record)
          }}/>
          <DeleteOutlined onClick={()=>{
            onDeleteItems(record)
          }} style={{color:"red", marginLeft:12}}/>
            </>
        );
        }
    },
  ];

here are items showing in my console log enter image description here

here is my screen where i have to display my records enter image description here



Solution 1:[1]

dataIndex must be same as the property name in the response. for example for first column dataIndex should be 'itemName' which is property from the response.

So you columns object will be as follow

const columns = [
{
  title: 'Item Name',
  dataIndex: 'itemName',
  key: '1',
  render: text => <a>{text}</a>,
},
{
  title: 'Category',
  dataIndex: 'itemCategory',
  key: '2',
},
{
  title: 'Item Price',
  dataIndex: 'itemPrice',
  key: '3',
},
{
  title: 'Item Amount',
  dataIndex: 'stockAmount',
  key: '4',
},

{
  title: 'Action',
  key: '5',
  render: (record) => {
    return(
      <>
      <EditOutlined onClick={()=>{
        onEditItems(record)
      }}/>
      <DeleteOutlined onClick={()=>{
        onDeleteItems(record)
      }} style={{color:"red", marginLeft:12}}/>
        </>
    );
    }
},
];

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ved