我有一个使用包 mui-datatables 的反应应用程序。我想在 RowClick 上重定向到“/edit-form”,但它不起作用(没有任何反应,也没有错误)。
import React, { Component } from "react";
import { Link as RouterLink } from "react-router-dom";
import Link from "@material-ui/core/Link";
import MUIDataTable from "mui-datatables";
class DataTable extends Component {
state={...}
redirectToForm = props => <RouterLink to="/edit-form" {...props}/>
render() {
const options = {
onRowClick: rowData => this.redirectToForm(rowData)
};
return (
<Link
color="secondary"
className={classes.button}
component={this.goToDetailedTable}
>
Detail
</Link>
<MUIDataTable
title={title}
columns={value.state.columnName}
data={value.state.rowData}
options={options}
/>
)
}
当我 console.log(rowData) 时,它确实打印出了行数据:
const options = {
onRowClick: rowData => console.log(rowData)
};