DEV Community

Discussion on: Simple React DataTable

Collapse
 
hhsm95 profile image
Hugo Sandoval • Edited

Yeah, I updated the component to support a function in the columns to customize the field. Example to insert an image and delete button:

const columns = [
    { title: 'Picture', format: (row) => (<img src={row.image} alt={row.title} />) },
    { title: 'Delete', format: (row) => (<button type="button" onClick={() => deleteImage(row.id)}>Delete</button>) },
  ];

const deleteImage = (id) => {
  console.log(id);
}
Enter fullscreen mode Exit fullscreen mode