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?

0

1 Answer 1

3

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

<Route path="/etc/:id?">
    <Component />
</Route>
Sign up to request clarification or add additional context in comments.

1 Comment

@free_lions_n_tigers_from_cages, check this out!!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.