function StyledSelectedRow() {
const [selectedRow, setSelectedRow] = React.useState(null);
return (
<MaterialTable
data={[
{
name: "Mehmet",
surname: "Baran",
birthYear: 1987,
birthCity: 63,
},
{
name: "Zerya Betül",
surname: "Baran",
birthYear: 2017,
birthCity: 34,
},
]}
columns={[
{
title: "Name",
field: "name",
},
{ title: "Surname", field: "surname" },
{ title: "Birth Year", field: "birthYear", type: "numeric" },
{
title: "Birth Place",
field: "birthCity",
lookup: { 34: "İstanbul", 63: "Şanlıurfa" },
},
]}
onRowClick={(evt, selectedRow) =>
setSelectedRow(selectedRow.tableData.id)
}
options={{
rowStyle: (rowData) => ({
backgroundColor:
selectedRow === rowData.tableData.id ? "#6ABAC9" : "#FFF",
}),
}}
/>
);
}