Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

104
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda