I am trying to create this button that works well when I am using the map() function :
{bands.events.map((group, i) => (
<tr key={i}>
<td>{group.start}</td>
<td>
{" "}
<button value={group.name} onClick={props.handleClickGroup}>
{group.name}
</button>
</td>
</tr>
))}
However, now I want to use react-table to filter the dates in time order and enable other features, however I can't seem to find the way to add this button and print out the data of the local json inside the button element. This is my code:
import React from "react";
import ReactTable from "react-table";
import "react-table/react-table.css";
var bands = require("../festivals/bands.json");
const FestivalTable = props => {
const columns = [
{
width: 200,
Header: "Time",
accessor: "start"
},
{
width: 300,
Header: "Artist Name",
accessor: "name",
Cell: cell => (
<button value={cell.accessor} onClick={props.handleClickGroup}>
{cell.accessor}
</button>
)
}
];
return (
<ReactTable
data={bands.events}
columns={columns}
minRows={0}
showPagination={false}
//getTdProps={bands.events}
/>
);
};
export default FestivalTable;
Then in the parent component, I have put:
<div className="table-wrap">
<FestivalTable handleClickGroup={props.handleClickGroup} />
</div>