News for hackers. Stuff that matters.
Re:Persisting React State in LocalStorage by dudus on Friday February 28, 2020 @11:56AM (#22444165)
I remember people were abandoning localstorage a while ago because of some fundamental problem I can't quite remember right now. Not sure if it was difficulty in keeping in sync which the author mentions or the fact that it can't be scoped in a way to share among subdomains. I'm sure someone here will have a better memory than me.

Edit: after some basic research among other complaints are: bad performance, synchronous, bad security model, only strings, limited to 5mb, no access to web workers.

Localstorage has its uses but shouldn't be abused to store everything in it.

Re:Persisting React State in LocalStorage by tptacek on Friday February 28, 2020 @01:27PM (#22445043)
The "bad security model" applies to storing things like tokens; it's an argument against using JWTs and localStorage as an alternative to secure cookies. It doesn't apply here.
Re:Persisting React State in LocalStorage by Drdrdrq on Friday February 28, 2020 @03:46PM (#22446192)
Re web workers: is anyone (apart from Google) using this in practice? I assume Photopea and similar apps could benefit from it in some specific cases, but haven't had the need for them myself. Am I missing something?
Re:Persisting React State in LocalStorage by stekern on Saturday February 29, 2020 @02:38AM (#22449487)
I've experimented with using it together with TensorFlow.js to avoid blocking the UI thread while performing computationally expensive operations. Operations do take a bit longer to complete in a web worker compared to the main thread, but in return you get a smooth UI and a better user experience
Re:Persisting React State in LocalStorage by ficklepickle on Saturday February 29, 2020 @02:55AM (#22449535)
Last I checked, they can only pass messages to the main thread as strings. All that (de)serialization can easily become a bottleneck, depending on the workload.
Re:Persisting React State in LocalStorage by crubier on Friday February 28, 2020 @03:52PM (#22446256)
Yes we use it for relatively heavy processing in our web app. To not block the UI and allow offline use