title: react-router generatePath() with optional path params
body: <p>I'm having a path like <code>to/:param/(optional)?/:optionalParam?</code> so when I use <code>generatePath()</code> like:</p>
  <pre><code>generatePath('to/:param/(alsoTo)?/:optionalParam?', {
    param: 'abc',
    optionalParam: 'xyz',
  });
  </code></pre>
  <p>I get something like <code>to/abc/xyz</code> instead of <code>to/abc/alsoTo/xyz</code> (the former misses <code>alsoTo</code> in the path).</p>
  <p>What should I do to get <code>to/abc/alsoTo/xyz</code> with <code>/alsoTo/</code> in the generated path as well?</p>
  <p>I'm using react-router v5.</p>