reactjs - 使用 NavLink 重定向组件 onClick
问题描述
使用带有 React Hooks 的 Material Table 我的愿望是重定向 onClick。目前 onClick 没有响应。
材料表组件
actions={[
{
onClick: (items) => {
/*
I want to re-direct to another route("/editperson") +
component(EditPerson.tsx) and send it props from this component
*/
}
}
]}
NavigateToEditPerson.tsx
function NavigateToEditPerson() {
return (
<>
<NavLink to={{ pathname: "/editPerson" }} />
</>
);
}
解决方案
You can simply use the useHistory hook and call history.push(/editPerson/${item.name}
) for example to route to that link. If you use react router, you can access the params with useParams, if you declared that in the route definition.
But since this is neither an issue nor has something fundemental to do with the table itself, I would recommend to close this issue. This should be ask in the Forum or on stack overflow. Thank you.
推荐阅读
- vue.js - Vuejs 通过数据属性动态加载指令
- hyperledger-fabric - 如何在 Hyperledger Fabric SDK 中将多个事务批处理到一个 GRPC 调用中?
- c# - Microsoft.EntityFrameworkCore 未在 Web API .NET Core 应用程序中安装和挂起 - Visual Studio 2019
- javascript - 为什么 JavaScript 中的 tab 等于 false?
- json - 如何在我的 gist 上将我的 json 简历下载为 pdf 格式?
- python - matplotlib 删除 IndexError: tuple index out of range after upgrade
- javascript - 从 Vue.js 向烧瓶发送 POST 请求
- c# - 将复杂的 Json 转换为 Object
- android - 如何让 Recyclerview 显示 Retrofit 的结果?
- r - 如何根据组内的子字符串匹配两个数据帧