Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle multiple params #52

Closed
birendra-90 opened this issue Jan 16, 2019 · 1 comment
Closed

Handle multiple params #52

birendra-90 opened this issue Jan 16, 2019 · 1 comment
Labels

Comments

@birendra-90
Copy link

How to handle multiple params?

e.g. /products/:productId/categories/:categoryId

@icd2k3
Copy link
Owner

icd2k3 commented Jan 16, 2019

Hi @birendra-90 👋

This is supported. With defaults enabled you could do something like this:

const routes = [
  { path: '/products/:productId', breadcrumb: ({ match }) => <span>{match.params.productId}</span> },
  { path: '/products/:productId/categories/:categoryId', breadcrumb: ({ match }) => <span>{match.params.categoryId}</span> },
];

withBreadcrumbs(routes)(MyComponent)

For the above:
URL: /products/1/categories/2
Breadcrumbs: Home / Products / 1 / Categories / 2

This will work with default breadcrumbs option disabled too. You'd just have to define route breadcrumbs for 'products' and 'categories'.

Hope that helps!

@icd2k3 icd2k3 closed this as completed Feb 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants