【发布时间】:2022-01-11 14:07:42
【问题描述】:
当用户点击EDIT 图标时,将打开一个页面。在用户submit 记录之后,如果成功,我们的页面应该重定向到ListCertificate。
当用户点击编辑按钮时,下面的行将运行。并打开编辑表单。
<Link to={`/${props.certificate.id}/edit` }>Edit</Link>
用户保存成功后,我们的页面应该重定向到ListCertificate组件。
所以我写了
.then(function (response: any) {
console.log(response);
toast("???? Record updated successflly", {
position: "top-right",
autoClose: 2000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined
});
return <Redirect to='/listcertificate' />
})
这条线不工作。
return <Redirect to='/listcertificate' />
在 app.js 中,我使用下面的方法调用了 ListCertificate。
<Route path ="/listcertificate" component={Listcertificate} ></Route>
localhost:4200/listcertificate 工作正常。但它也没有从editcomponent重定向到同一页面。
【问题讨论】:
-
你使用什么版本的 react-router-dom?
-
谢谢.........它是 6.0.2
标签: javascript reactjs typescript react-router