Linked Questions
23 questions linked to/from React Router with optional path parameter
0
votes
2
answers
475
views
How to match optional parameter in url? [duplicate]
Is it possible to use optional parameter for url?
For example path fruits/:id will match the same component if parameter id is not passed;
<Route path="/fruits/:id">
<Fruits />
...
2
votes
1
answer
76
views
How to make URL parameter matching optional [duplicate]
<Route path="/etc/:id/">
<Component />
</Route>
I notice, if :id is not provided, then it wouldn't match.
How do I change it so that :id is optional?
49
votes
6
answers
37k
views
Alternate way for optional parameters in v6
In v5, we could add trailing ? to route for optional parameters, but as in v6, the support for the same has been dropped, so what's the alternate way of writing the following piece of code?
<Route ...
15
votes
2
answers
7k
views
Exclude a value for a path parameter in React Router by type
I'm a bit stuck with the route component. Imagine I have this two Routes with their own path:
<Route path='/person/add' exact component={PersonForm}/>
<Route path='/person/:id' exact ...
13
votes
2
answers
7k
views
React Router 4 with optional path AND optional parameter
Need to declare an optional path that contains a string and a parameter
Now I have this path
<Route exact path="/tasks/:id" render={(props) => (
<AsyncTask {...props} profile={this.state....
7
votes
1
answer
20k
views
How to set route with optional query parameter using React router?
I have a path as
<Route path="/account/:accountid/LoginPage"
component={LoginPage}/>
This works fine if the url is -> /account/12332/LoginPage. I want to have optional query parameters. ...
10
votes
1
answer
6k
views
How to set an optional parameter on root route in react-router v4?
Let's say I have the following 2 routes:
...
<Route exact path="/:param1?/" component={Home}/>
<Route path="/news" component={News}/>
...
now when I try to hit route /news ...
6
votes
1
answer
10k
views
Optional React Router parameter
I'm trying to create a route that matches all of the following URLs:
/product/foo
/product/foo/bar
Here's my current route:
<Route path="/product/:productName(/:urlID)" handler={SomeHandler} />...
2
votes
1
answer
3k
views
URL parameter with React-Router
//ArticlePage
const ArticlePage = ({ match }) => {
const name = match.params.name;
return (
<>
<h1>
This is {name} Article
</h1>
</&...
5
votes
2
answers
1k
views
React-router optional path parameters at root
I am a little confused on how to do (multiple) optional path parameters from the root. I'm using react-router 3, and redux 4.3.
From what I understand, (/:param1)(/:param2) should work, but I am ...
0
votes
1
answer
1k
views
match route that has param doesn't work with react-router v4
<Route path='/change-password/?resetToken=(:token)' component={()=><h1>testing</h1>} />
Above route don't render when I hit the url below?
http://localhost:3000/change-password/?...
1
vote
1
answer
836
views
From static pagination to dynamic
Need help with pagination. Right now my app can change page, but if I want send request like /character?page=4 it always throw me /character?page=1 this is not help, coz I use router. I have no idea ...
0
votes
1
answer
628
views
How Can I Have Optional *Non*-Parameter URL Parts?
This Stack Overflow question/answer explains how to define React Router (v4) routes which contain multiple optional parameter, eg.:
<Route path="/to/page/:pathParam1?/:pathParam2?" component={...
0
votes
1
answer
435
views
Simple React Router with an Optional Path Parameter gives 'TypeError: Cannot read property 'filter' of undefined'
I have this simple enough React app (created with create-react-app 1.5.2, and fluff removed). It has by default installed react-router 4.2.0.
// index.js
import React from 'react';
import ReactDOM ...
0
votes
2
answers
576
views
Navigating to optional parameters with React Router
I am trying to make optional sub routes with my React Router but no matter what I search I can't seem to find a solution that works for me !
I tried every solution mentioned in this answer:
React ...