React - How to get parameter value from query string?

后端 未结 30 2281
温柔的废话
温柔的废话 2020-11-22 10:22

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 a

30条回答
  •  广开言路
    2020-11-22 10:47

    Maybe someone can help clarify why but if you're attempting to hit props to find location from a fresh install of Create React App on the App.js page you get:

    TypeError: Cannot read property 'search' of undefined

    Even though I have App.js as the home route:

     (
    

    On App.js only, using window.location worked for me:

    import queryString from 'query-string';
    ...
    const queryStringParams = queryString.parse(window.location.search);
    

提交回复
热议问题