Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

103
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda