例如,我想使用id
作为通过row.values在Actions组件中的Actions头中传递的东西。虽然我可以获得名字和姓氏的值,但我不能获得id
const Accounts = () => {
const [columns,setColumns] = useState(useMemo(() => [
{
Header: 'First Name',
accessor: 'firstName',
},
{
Header: 'Last Name',
accessor: 'lastName',
},
{
Header: 'Actions',
Cell: ({row}) => (
<Actions values={row.values}/>
)
}
],
[]
));
const [data,setData] = useState(useMemo(() => [
{
id:1,
firstName:"john",
lastName:"johnson",
},
{
id:2,
firstName:"dave",
lastName:"jones",
},
{
id:3,
firstName:"steve",
lastName:"smith",
},
], []));
return (
<>
// react-table component
<Table columns={columns} data={rdata}/>
</>
)
}
您可以使用row.original 访问所有行数据