2 ms·
I'm sure there's a billion reasons for frontend frameworks not really worth debating here, but I was curious about this: > It could be that many people struggl
by solardev 3y ago
I'm sure there's a billion reasons for frontend frameworks not really worth debating here, but I was curious about this:
> It could be that many people struggle with the DOM, but anyways it’s all APIs and event handling.
Without a framework, how do you usually like to handle cross-component/cross-screen state in the frontend? Like where do you keep track of logged-in state, dark mode, the shopping cart, etc? Do you just like to put that in the backend, or is there a neat way to organize such data in vanilla JS in the frontend?
- austin-cheney 3y agoI keep state in a single object. State management is ridiculously simple but people tend to make it more challenging than it needs to be. I then send the data stored in that object out of the browser as determined by the app for storage at the server. Restoring state is as simple as embedding the state data directly into the static html so that it’s always there as fast as possible every time the page is requested.
- solardev 3y agoSounds like using "window" as a big global variable, but cached on the backend almost like a manual cookie? Well typed, I'd imagine the dev ex would be similar to a monolithic React context. Seems like it'd work.