2
          <Route path="/etc/:id/">
            <Component />
          </Route>

I notice, if :id is not provided, then it wouldn't match.

How do I change it so that :id is optional?

1 Answers1

3

You should add a question mark at the end of the param to make it optional

<Route path="/etc/:id?">
    <Component />
</Route>
Amila Senadheera
  • 12,229
  • 15
  • 27
  • 43