Alternatives to the Query-string managing state

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Alternatives to the Query-string managing state



We're using React redux, which is fantastic. However, the moment someone refreshes their browser we lose the Redux store and as a result the application breaks or needs to redirect back to the 'start'.



We are using the Query-string to manage this, but I have been told Management this is 'Ugly' and we should find an alternate place to hold this information and remove it from the URL.



My understanding is we could use a number of things; Cookies, local storage, session storage etc.



However, I don't know which is the best to use.



We're essentially just looking for somewhere to move the information contained in the URL. E.G. https://url.com?querystring=12345&non-sensitive-id=2242





Redux persist exists.
– Li357
11 mins ago




1 Answer
1



You can use localStorage of HTML5.
To store data:




//To store data:
localStorage.setItem("key", 'value');
//To access data:
localstorage.getItem("key");
//and to remove from local storage,
localStorag.removeItem("key");






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results