Ad

React-router TransitionTo: Invariant Violation: Missing "splat" Parameter For Path

- 1 answer

I am using react-router with react.

I need to use query strings in my url like this:

let url = '/some/path/legal?id=2&name=QA_3%206*6*6';
this.context.router.transitionTo(url);

However, it does not do the redirect and throws an error:

Unhandled promise rejection Error: Invariant Violation: Missing "splat"  parameter for path "/some/path/legal?id=2&name=QA_3%206*6*6"

Seems that the splat (*) is not allowed in the query strings?

Ad

Answer

I haven't used this old version of react-router, but it looks like the signature is:

routeName (string), params (object), query (unused)

So try:

this.transitionTo('/some/path/legal', { id: 2, name: 'QA_3%206*6*6' });

I would have thought it'd be a querybut it seems that is unused.

Ed/rackt/react-router/issues/1148" >but it seems that is unused.

Edit, OP tested and seems it's used, so:

this.transitionTo('/some/path/legal', null, { id: 2, name: 'QA_3%206*6*6' });

Perhaps think about update to at least v1, which doesn't use transitionTo anymore. See https://github.com/rackt/react-router/blob/master/upgrade-guides/v1.0.0.md#navigation-mixin.

Ad
source: stackoverflow.com
Ad