react-router icon indicating copy to clipboard operation
react-router copied to clipboard

id missing form params passed to handler

Open lubelski opened this issue 12 years ago • 7 comments

I feel like I'm missing something basic.

the props.params in my handler does not contain one of the IDs that I need.

One Route looks like:

Route name: 'Baz Editor Route', path: '/foo/:fooId/bar/:barId/baz/:bazId/', handler: BazEditor

for url: /foo/1/bar/1/baz/1, in render for BazEditor, if I console.log this.props.params, I get

{fooId: 1, barId: 1}

instead of what I expected, which would be:

{fooId: 1, barId: 1, bazId: 1}

is bazId suppsed to be passed into the handler? It seems like the entire point, so I assume I missing something basic.

Thanks,

-Will

lubelski avatar Aug 27 '14 22:08 lubelski

sweet mother of god, hunt for an hour, post an issue, find it 5 minutes later.

lubelski avatar Aug 27 '14 22:08 lubelski

what was the issue?

ryanflorence avatar Aug 27 '14 22:08 ryanflorence

looks like a ... wait for it ... TRAILING SLASH ???

mjackson avatar Aug 27 '14 22:08 mjackson

omg, it was so dumb. Earlier I had been messing around with passing params to subviews to get links to work.

After rechecking my routes definitions, rechecking a bunch of Links() and even reading through a bunch of the source and some 0.6 changes stuff, I finally looked at the parent view and found this gem:

@props.activeRouterHandler(params:@props.params)

lubelski avatar Aug 27 '14 23:08 lubelski

Might want to throw an error if you try to override params to activeRouteHandlers. I can't imagine a reason you'd actually want to do this, and you could always pass otherParams:@props.params if you really wanted to.

lubelski avatar Aug 28 '14 21:08 lubelski

or just not take them, maybe.

ryanflorence avatar Aug 28 '14 21:08 ryanflorence

Yeah, ignore passed params + console warning seems reasonable. On par with React's "bro, you need keys for your array" message.

lubelski avatar Aug 31 '14 21:08 lubelski