How do you programmatically update URL params in react-router?

僤鯓⒐⒋嵵緔 提交于 2020-01-03 03:01:34

问题


This answer doesn't quite cover it since it appears that you have to pass a reconstructed URL into pathname

If I am on the child page of these routes:

  <Route name="Parent" path="/parent/:parentId" component={Parent}>
    <Route name="Child" path="/child/:childId" component={Child}>

how do I programmatically update the :parentId without having to re-construct the entire URL?

Something along the lines of history.push({ ...., params: {parentId: 'newParent'}}) would be ideal.

Thanks!

来源:https://stackoverflow.com/questions/42729802/how-do-you-programmatically-update-url-params-in-react-router

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!