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

235
Vistas
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 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