Optional React Router parameter

前端 未结 1 420
[愿得一人]
[愿得一人] 2021-01-12 16:44

I\'m trying to create a route that matches all of the following URLs:

/product/foo
/product/foo/bar

Here\'s my current route:



        
相关标签:
1条回答
  • 2021-01-12 17:24

    Okay so the () syntax is specific to React Router 1.0, not 0.13.3. I ended up using the ? syntax:

    <Route path="/product/:productName/?:urlID?" handler={SomeHandler} />
    
    0 讨论(0)
提交回复
热议问题