question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Accessing query params from React-router

See original GitHub issue

Hi,

I’ve been facing problems accessing the query params from the router. The reduxAsyncConnect method exposes the params argument which has only the declared arguments but not the query values. I need them in the static method for server access. How do I do this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
oyeanujcommented, Jun 20, 2016

Ah, I asked too soon. I found the answer here for anyone else coming to look for it in the future. Maybe this should be documented -

https://github.com/Rezonans/redux-async-connect/issues/53#issuecomment-191527313

Relevant bit:

@asyncConnect([{
  promise: (options) => {
    const {
      store: { dispatch },
      params: { id },
    } = options;

    return dispatch(loadYourDataWidget(id));
  },
}])

Here are the full set of properties on that options object passed in.

store - commonly accessed props dispatch and getState params - the route params helpers matchContext router history location routes

1reaction
sungwonchocommented, Aug 22, 2016

For anyone with the same problem, try loadOnServer({ ...renderProps, store, helpers: { client } }).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get parameter value from query string? - Stack Overflow
React Router v4 ; url = · const yourParamName = url.searchParams.get('yourParamName');. In short ; yourParamName = · searchParams.get('yourParamName'). Another ...
Read more >
React Router - Query Parameters
React Router - Query Parameters. A simple example deployed using react-codesandboxer. 116. 0. 0. Edit Sandbox. Files. example.js. index.html. index.js.
Read more >
Getting Query Strings (Search Params) in React Router
Get all Query String values as an object ... We could use some array destructuring to get the param name and the value:...
Read more >
How to get Query Parameters and URL Parameters in React
Tutorial on different ways to read query and URL parameters. Explains about how to get query & URL parameters using URLSearchParams, ...
Read more >
How to get the query params in React - Reactgo
Query params are passed to the end of a URL using question mark ? followed by the key=value pairs. ... To get the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found