0

I have created the following routes using connected-react-router as shown below

<Switch>
    <Route exact={true} path="/a" component={A}/>
    <Route exact={true} path="/b" component={B}/>
    <Route path="/c/:id" component={C}/>
</Switch>

But when I hit the url my.domain.com/c, the component does not get render. But when I go and give the url my.domain.com/c/12, then it works. I have tried setting exact={false} as well. Still it does not work. Any help will help me proceed further.

RushilAhuja
  • 35
  • 1
  • 9

1 Answers1

0

When you declare the route:

<Route path="/c/:id" component={C}/>

You are saying that the "id" it's mandatory. If you need render the page even if the user don't pass the id, you need to add "?":

<Route path="/c/:id?" component={C}/>
Ownard
  • 1