|
|
|
|
|
by doradoblank
315 days ago
|
|
How do you handle state that affects multiple components? Like a filter button that affects a list table. In React you just hoist the state up and make both components dependent. If you're managing all state via internal component state, then you need to explicitly pass state between the components. That's okay for simple cases, but in my experience it breaks down pretty quickly. Once you have more than a few components involved, you end up writing your own state reconciliation. |
|
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.
[1] https://claytongulick.github.io/applicationstate/