querystrings in state
See original GitHub issueThe 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:
- Created 6 years ago
- Comments:28 (15 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 theback
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.
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.