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

241
Visualizações
React Carbon DataTable not getting onclick event (value) for the selected

Am just exploring react with carbon and got stuck with some trigger event. Here is my piece of code (ChildComponent)

<DataTable rows={rows} headers={headers} size='tall' zebra>
      {({ rows, headers, getTableProps, getHeaderProps, getRowProps }) => (
        <Table {...getTableProps()}>
          <TableHead>
            <TableRow>
              {headers.map((header, i) => (
                <TableHeader key={i} {...getHeaderProps({ header })}>
                  <React.Fragment>{header.header}</React.Fragment>
                </TableHeader>
              ))}
            </TableRow>
          </TableHead>
          <TableBody>
            {rows.map((row, j) => (
              <div key={row.id}>
                <TableRow key={row.package} {...getRowProps({ row })}>
                  <>
                    {row.cells.map((cell) => (
                      <>
                        <TableCell key={cell.id}>{cell.value}</TableCell>
                      </>
                    ))}
                    <Button color='primary' id={row.package} onClick={this.props.redirectToDesigner(row.package)}>
                      Open
                    </Button>
                  </>
                </TableRow>
                <br />
              </div>
            ))}
          </TableBody>
        </Table>
      )}
    </DataTable>

THis lies on child component and Parent component looks like below

import React from "react";
import ChildComponent from "./ChildComponent";

class ParentComponent extends React.Component {
  redirectToDesigner = (id) => {
    alert(1);
    console.log("TRYYYY", id);
  };
  render() {
    return <ChildComponent redirectToDesigner={this.redirectToDesigner} />;
  }
}
export default ParentComponent;

Am getting the alert and the console as undefined for some reason

Here you can see one onclick event , its triggering but am not getting value(row.id) from it. I need the value for further development.

Any help/fiddle will be highly helpful

about 4 years ago · Juan Pablo Isaza
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