News for hackers. Stuff that matters.
Re:How UI-driven state increases accidental complexity by runawaybottle on Wednesday March 25, 2020 @02:29AM (#22682425)
So my initial feeling is that it almost seems like you are reimplementing base React. Isn’t this effectively prop drilling, with a bunch of child components lifting state up to the global parent component (so that they all get updates?). Apologies if I’m simplifying it.
Re:How UI-driven state increases accidental complexity by viklove on Wednesday March 25, 2020 @02:37AM (#22682474)
Well I'm using React so I can't be re-implementing it :)

I'm not advocating for any ground breaking paradigms here, I guess my only point is that the common advice to just throw everything into Redux (global store) is bad advice. You should only put global state into your global store. The common alternative is to silo state and functionality/UI into one component. I'd argue the third alternative, taking the best of both worlds, enables far more productivity. Basically creating mini-Redux stores that are only focused on one bit of user interaction. These are far more reusable, and since they're scoped locally they eliminate a lot of edge cases (and they're composable!).

Re:How UI-driven state increases accidental complexity by nine_k on Wednesday March 25, 2020 @02:58AM (#22682542)
This sounds quite nice. I wonder if proper Redux stores could be used for that (because you can create many of them).
Re:How UI-driven state increases accidental complexity by bryanrasmussen on Wednesday March 25, 2020 @09:48AM (#22684465)
Since he's using the context api https://reactjs.org/docs/context.html not exactly.

Imagine you have a React tree with a 100 node depth. You would then need to walk all the way up those 100 nodes, but using the context api you can put in context consumer at the branches of your tree where it makes sense, so instead of walking up 100 nodes you walk up 3 nodes to input into the global context.

Hope that is a reasonable high level explanation of a thing that can be complicated without experience of it.

Re:How UI-driven state increases accidental complexity by onion2k on Wednesday March 25, 2020 @03:03AM (#22682557)
Contexts were added to React to replace prop drilling.