How to make URL parameter matching optional

Viewed 35
          <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 Answers

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

<Route path="/etc/:id?">
    <Component />
</Route>
Related