Asked  7 Months ago    Answers:  5   Viewed   57 times

How can I define a route in my routes.jsx file to capture the __firebase_request_key parameter value from a URL generated by Twitter's single sign on process after the redirect from their servers?


I tried with the following routes configuration, but the :redirectParam is not catching the mentioned param:

  <Route path="/" component={Main}>
    <Route path="signin" component={SignIn}>
      <Route path=":redirectParam" component={TwitterSsoButton} />



React Router v4 and React Router v5, generic

React Router v4 does not parse the query for you any more, but you can only access it via (or useLocation, see below). For reasons see nbeuchat's answer.

E.g. with qs library imported as qs you could do

qs.parse(, { ignoreQueryPrefix: true }).__firebase_request_key

Another library would be query-string. See this answer for some more ideas on parsing the search string. If you do not need IE-compatibility you can also use

new URLSearchParams("__firebase_request_key")

For functional components you would replace this.props.location with the hook useLocation. Note, you could use, but this won't allow to trigger React rendering on changes. If your (non-functional) component is not a direct child of a Switch you need to use withRouter to access any of the router provided props.

React Router v3

React Router already parses the location for you and passes it to your RouteComponent as props. You can access the query (after ? in the url) part via


If you are looking for the path parameter values, separated with a colon (:) inside the router, these are accessible via


This applies to late React Router v3 versions (not sure which). Older router versions were reported to use this.props.params.redirectParam.


nizam.sp's suggestion to do


will be helpful in any case.

Tuesday, June 1, 2021
answered 7 Months ago
>>> import re
>>> string1 = "498results should get"
>>> int('d+', string1).group())

If there are multiple integers in the string:

>>> map(int, re.findall(r'd+', string1))
Wednesday, June 9, 2021
answered 7 Months ago

You are missing a constructor method with a call to super(). super() calls the constructor of the parent class and is needed to properly pass the properties of the parents class to this component. You would need this to access any properties passed to the component, including router.

The top of your layout class should look like this.

export default class Layout extends React.Component {
  constructor(props) {

  navigate() {

  render() {

Here are the docs on how classes work in ES6!

Edit 1: React Router

You also need to use the new withRouter when doing navigation via this.props.router. You do this by passing your component as an argument and exporting that. The withRouter function just wraps your component in another component that passes the router prop down to your component. I should point out that there are other ways of doing programmatic routing (singletons, context, etc.), but when using this.props.router.push you will need to use withRouter.

import { withRouter } from 'react-router' 
class Layout extends React.Component {
  constructor(props) {

  navigate() {

  render() {

export default withRouter(Layout)

Using withRouter

Friday, August 13, 2021
answered 4 Months ago

Use the following code:

    public ActionResult method()
        string param1 = this.Request.QueryString["param.1"];
        string param2 = this.Request.QueryString["param.2"];

Wednesday, October 6, 2021
answered 2 Months ago

You only need to have on BrowserRouter in your component so that all Routes are aware of which Router they are subscribing to and at the same time Links are updating data in the correct Router Provider.

In your case, Header and Root elements are wrapped by Different BrowserRouter and hence the Links in Header component update the enclosing Router Provider, which the other Routes in index.js file aren't subscribing to and hence it doesn't work correctly.

So instead of rendering different elements with ReactDOM.render, you can do it simply like

import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import Home from './Home';
import Header from './Header';
import Footer from './Footer';
import Resume from './Resume';
import * as serviceWorker from './serviceWorker';

          <div id="header">
            <Route component={Header} />
              <Route exact path ="/" component={Home} />
              <Route path ="/resume" component={Resume} />
          <div id="footer">
            <Route component={Footer} />
), document.getElementById('root'));


And Header.js

import React, { Component } from 'react';
import bImg from './img/moi2.jpg';
import { BrowserRouter, Link } from 'react-router-dom';

 * Composant définissant l'entête de la page (Navigation et la photo de début)
 * Link est utilisé à la place de <a> pour la gestion des routes.
 * @Author 
 * @date 15th november 2018

class Header extends Component{
                    <nav className="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav">
                        <div className="container">

                            <Link className="navbar-brand" to="/">Iam Root</Link>

                            <button className="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse"
                                    data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false"
                                    aria-label="Toggle navigation">
                                <i className="fas fa-bars"></i>

                            <div className="collapse navbar-collapse" id="navbarResponsive">
                                <ul className="navbar-nav ml-auto">
                                    <li className="nav-item">
                                        <Link to="/resume">Mon CV</Link>
                                    <li className="nav-item">
                                        <Link to="/tutoriels">Tutoriels</Link>
                                    <li className="nav-item">
                                        <Link to="/contact">Contactez-moi</Link>

                <header className="masthead" style={{backgroundImage: `url(${bImg})`}}>
                    <div className="overlay"></div>
                    <div className="container">
                        <div className="row">
                            <div className="col-lg-8 col-md-10 mx-auto">
                                <div className="site-heading">
                                    <h1 style={{ opacity: 0.4}}>prenom nom</h1>
                                    <span className="subheading">

export default Header;

Once you make this change, your App should work as desired

Tuesday, November 16, 2021
answered 3 Weeks ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :