question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Optional Url Params

See original GitHub issue

Hi,

Love the project; thanks,

I have a problem with a path with an optional parameter.

When navigating to /sensor/register the breadcrumb shows:

Register Sensor

but navigating to /sensor/register/123 results in:

Register Sensor / Register Sensor

I have the following path setup in my routes.config - the offending route is at the bottom…

const routesConfig = [
  {
    path: '/hubs',
    exact: true,
    component: MyHubsContainer,
    breadcrumb: 'My Hubs'
  },
  {
    path: '/hubs/register',
    exact: true,
    component: RegisterHubContainer,
    breadcrumb: 'Register Hub'
  },
  {
    path: '/hubs/:hubId',
    exact: true,
    component: HubDashboardContainer,
    breadcrumb: HubBreadcrumbItem
  },
  {
    path: '/hubs/:hubId/sensor/:sensorId/:sensorName',
    exact: true,
    component: SensorDetailContainer,
    breadcrumb: SensorBreadcrumbItem
  },
  {
    path: '/sensor/instructions',
    exact: true,
    component: InstructionsContainer
  },
  {
    path: '/sensor/register/:hubId?',
    exact: true,
    component: RegisterSensorContainer,
    breadcrumb: 'Register Sensor'
  }
]
const MainRoutes = (props) =>
  <Switch>
    {routesConfig.map((route, i) =>
      <Route
        exact={route.exact}
        key={route.path}
        path={route.path}
        component={route.component}
      />)}
  </Switch>
const Breadcrumbs = ({ breadcrumbs }) =>
  <div>
    {breadcrumbs.map((breadcrumb, index) => (
      <Link key={breadcrumb.key} to={breadcrumb.props.match.url || ''}>
        {breadcrumb} {console.log('breadcrumb', breadcrumbs.length, breadcrumb)}
      </Link>
    ))}
  </div>

Any ideas?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
icd2k3commented, Jun 16, 2018

Hey @luke-unifymonitor this key warning is fixed in 2.1.4. Here is the updated code sandbox: https://codesandbox.io/s/13j7vr75yl

0reactions
icd2k3commented, Jun 15, 2018

🤔 I should fix that warning. I’ll look into this case in the near future.

Thanks for the reply and the code sandbox @luke-unifymonitor !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Optional Parameters | FastSpring Classic Documentation
Sometimes you may want customers to see a specific state or version of your store. One common way to accomplish this is to...
Read more >
Optional URL Parameters - Mapp documentation
Optional URL Parameters. In Mapp Intelligence, it is possible to send a variety of additional pre-defined or custom parameters.
Read more >
How to access optional URL parameters in Express.js?
You have multiple consecutive optional parameters in your URL. When you hit localhost:3000/show/luis/California/123, express had no way of ...
Read more >
Passing Optional Parameters to a Route - Rangle.io
Query parameters allow you to pass optional parameters to a route such as pagination information. ... The key difference between query parameters and...
Read more >
React Router: Optional Parameters - DigitalOcean
The route will be rendered if it matches the path, with or without the optional parameter. So '/Lyrics/Spoonman' and '/Lyrics/Spoonman/3' would ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found