1

I have some paths that currently look like this:

const baseUrl = `${mainUrl}/web`;

<Route exact path={baseUrl} component={Goods} />
<Route exact path={`${baseUrl}/:ID`} component={Good} />
<Route exact path={`${baseUrl}/:ID/details`} component={GoodDetails} />

Now, this works all fine, but what I instead want to do is that I want to render Good component, only if the URL matches this ${this.baseUrl}/:ID condition that we have, or if there is a query parameter called br=. I tried to do something like this:

<Route exact path={`${baseUrl}/:ID` | `${mainUrl}?br=:brInfo`} component={Good} />

But, this doesn't seem to work. Any ideas what is the proper way to this with React Router?

1 Answer 1

1

You can define two different routes to render the same component.

<Route exact path={`${baseUrl}/:ID`} component={Good} />
<Route exact path={`${mainUrl}?br=:brInfo`} component={Good} />
Sign up to request clarification or add additional context in comments.

1 Comment

This doesn't seem to match it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.