3 ms·
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 lif
by runawaybottle 7y ago
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.
- viklove 7y agoWell 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!).
- nine_k 7y agoThis sounds quite nice. I wonder if proper Redux stores could be used for that (because you can create many of them).
- deleted 7y ago[deleted]
- onion2k 7y agoContexts were added to React to replace prop drilling.
- bryanrasmussen 7y agoSince he's using the context api https://reactjs.org/docs/context.html 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.