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

missing parameter in seemingly correct route

Open tjwebb opened this issue 11 years ago • 4 comments

I've been banging my head against the wall on this for awhile now.

The error:

Uncaught Error: Invariant Violation: Missing "action" parameter for path "/collections/:action/tile"

the Route:

<Route name='Collection Tile View' path='/collections/:action/tile' handler={TileView} />

the URL I'm typing in my browser:

localhost/collections/create/tile

Shouldn't create match up with :action? Am I crazy? All my non-parameterized routes work great.

tjwebb avatar Mar 06 '15 08:03 tjwebb

Something is up, because:

Matches:

/collections/create --> /collections/:action?
(param.action = "create")

Error:

/collections/create --> /collections/:action

results in:

Missing "action" parameter for path "/collections/:action"

tjwebb avatar Mar 06 '15 08:03 tjwebb

My guess is that you somewhere have a <Link> without the action param.

agundermann avatar Mar 06 '15 17:03 agundermann

You should be getting UI, otherwise you'd get a "no route match path ..." in the console.

Drop a debugger at the warning then go up the stack to see where its coming from, @taurose is probably right.

Closing because there's a lot of example code and tests around this stuff and it smells like an application issue, not a router issue. Let me know if you find out anything new and we should reopen.

ryanflorence avatar Mar 25 '15 18:03 ryanflorence

I am encountering this errror when my app lives in a nested url http://myapp.com/projects/123.

If I use <Route name="home" path="/projects/123" handler={Root}>, all works as expected.

But, as if I use <Route name="home" path="/projects/:projectId" handler={Root}>, I get this same error for any route nested inside that root url.

(More detailed routing)

<Route path="/projects/:projectId" handler={Root} ignoreScrollBehavior={true}>
  <Route path="design-brief" name="design-brief" handler={DesignBriefIndex} />
</Route>

Error I receive:

Uncaught Error: Invariant Violation: Missing "projectId" parameter for path "/projects/:projectId/design-brief"

Any ideas?


Update

It seems that if you have any <Link> components in nested routes, they have to provide the params form the parent route.

Wanted to make sure I noted this incase I or anyone else runs into this obscure error message.

scottcorgan avatar Aug 19 '15 21:08 scottcorgan