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

114
Views
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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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}}/>
        </>
    );
    }
},
];
about 4 years ago · Juan Pablo Isaza Report
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!