FormidableLabs / redux-little-router

A tiny router for Redux that lets the URL do the talking.
MIT License
1.04k stars 114 forks source link

Nested dynamic link #221

Closed borisrorsvort closed 6 years ago

borisrorsvort commented 7 years ago

I'm trying to understand where I made a mistake. I have

A link:

<Link className='anything' href={`/tunebook/${tune.id}`}>
    {tune.name}
</Link>

Routes:

export const routes = {
  '/tunebook': {
    title: 'Tunebook',
    '/:tune_id': {
      title: 'Tune'
    }
  },
  '/': {
    title: 'Home'
  }
};

The main component:

<Fragment forRoute='/tunebook'><Tunebook /></Fragment>

and within Tunebook component:

<Fragment forRoute='/:tune_id'><Tune /></Fragment>

But when I click on the link, it doesnt get the params nor the route:

screen shot 2017-08-17 at 10 36 04

borisrorsvort commented 7 years ago

@tptee I just found out that if I replace tune_id with tuneId everything works. So that's probably a bug on the router params management side.

tptee commented 6 years ago

Hey @borisrorsvort ! Looks like underscores don't work in named fragments passed to url-pattern: https://www.npmjs.com/package/url-pattern#named-segments

Eventually we'll allow for custom url-pattern configs, but for now, your best bet is to use camelCase 😃