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.

querystrings in state

See original GitHub issue

The docs say

Intentionally we have chosen to solely support paths since they are best for SEO and keep the API minimal. You are free to use query strings to request data in your thunks.

This is a bit hand-wavy; I think it could be more helpful to explain what the intention is for thunks.

  • Should they be reading the querystring from the window.location object? If so, how is SSR indtended to work with querystrings?
  • Is the querystring stored in an undocumented part of the reducer state? If so, it should be documented.
  • Are thunks supposed to access the querystring in some other way?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:28 (15 by maintainers)

github_iconTop GitHub Comments

9reactions
kyeoticcommented, Jun 20, 2017

I think that is really going to complicate Components that do rely on querystrings. The querystring is part of the URL and an important piece of the state of pages that rely on them, like search pages. If the goal of this library is to say “Don’t use URLs, don’t think about the browser location, just use your application state” then not storing the querystring means you either can’t use querystring’s at all or you are violating the primary tenant of the library. Neither of those seem like great options.

To take it further, say I do get the querystring from some other place (like window.location), I am probably going to break the ability to replay/rewind redux actions. Will redux-first-router correctly restore querystrings to the URL if I use the back action? What about the url hash?

I don’t see how you can control the URL and but ignore querystrings; they are part of the URL.

6reactions
kyeoticcommented, Jun 20, 2017

Search results are the big one. If I perform two searches the back button should take me back to the first search. If the search is simple I guess you could still express that as a path component, but if the search is complex (multiple attributes) that would get difficult fast.

Read more comments on GitHub >

github_iconTop Results From Across the Web

the parameter " state " must be set in query string in result ...
You should get the state from the parameters that Google sends your auth endpoint in URL parameters. If you're using the implicit flow, ......
Read more >
Syncing query parameters with react state - Inkoop
Syncing query parameters with react state · It grabs all the current query parameters and stores them in the existingQueries variable. · It ......
Read more >
Using React Hooks to sync your component state and the URL ...
Many times we want to control parts of our app by modifying the query string parameters. Learn how you can do it by...
Read more >
A Guide to Query Strings with React Router - ui.dev
In this up-to-date guide, you'll learn what query strings are and how to use them using React Router's useSearchParams Hook.
Read more >
Hooks to persist state in the query string or history.state in React
The query string is a global state, so choose the parameter names wisely to prevent accidental clashes. But it is of course allowed...
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