How to do correct Relative Link in reach router?

14 views Asked by At

I have Router with 3 components. Page1, Page2, Page3 have common structure with common header and are switched by clicking on tab under this header. Page2Card should be opened in a new window. And differs from Page2 completely.

 <Router basepath={basepath}>
          <App path="/">
            <Page1 path="page1" />
            <Page2 path="page2" />
            <Page3 path="page3" />
          </App>
          <Page2Card path="page2/:cardId" />
          
  </Router>

Moreover, Page2Card should be opened in a new window. So, <Link /> isn't suitable. I use <a> to open it.

<a href={`page2/:${cardId}`}>Open in a new window</a>

Questions:

  1. How can I put component as a child inside routing. I tried. But this way doesn't work. Page2Card doesn't open.
    <Page2 path="page2" >
      <Page2Card path=":cardId" />
    </Page2>
  1. Is it true, that I use <a /> tag, because <Link /> doesn't have an opportunity to open in a new window?
0

There are 0 answers