title: How to link to current page with different param in react router?
body: <p>Let's say I have the following routes set up (just an example, actual routes aren't this messy):</p>
  
  <pre><code>&lt;Router&gt;
    &lt;Switch&gt;
      &lt;Route path="/app/fun/:userid/profile" component={Profile} exact/&gt;
      &lt;Route path="/photos/:userid" component={Photos} exact/&gt;
      &lt;Route path="/:userid/contact" component={Contact} exact/&gt;
    &lt;/Switch&gt;
  &lt;/Router&gt;
  </code></pre>
  
  <p>From <strong>ANY</strong> of the pages above, how can I link to the <strong>SAME</strong> page, but with a different <code>userid</code>?</p>
  
  <p>eg:</p>
  
  <pre><code>/**
   * Shared component that's rendered by Profile, Photos and Contact
   */
  class SharedComponent extends React.Component {
    render() {
      const bobId = 423423432;
  
      return (
        &lt;div&gt;
          &lt;Link to={/* what to put here? */}&gt;
            Redirect to the same page but with Bob's userid
          &lt;/Link&gt;
        &lt;/div&gt;
      );
    }
  }
  
  export default withRouter(SharedComponent);
  </code></pre>
  
  <p><em>Note: using react router v4</em></p>