by claytongulick · 1y ago · 0 comments
Just have each component maintain it's own state. Class setters work great. If you need the component to update, just call render() in the setter.
It's super simple, encapsulates logic, and brain-dead simple to debug. You know exactly where to go for everything: the component.
I've always felt like react's approach to state management was creating more problems than it solves.
One really easy way is to put a custom element at the root of the dom and just add/remove event listeners, maybe one-shot if that's all you need.
I also have a convenient little library called ApplicationState [1], which basically does the same thing but can persist state in indexdb.
Lots of other libraries out there too.