7 ms·
You have a root component. Run the interval within that component where you have access to state.
by badthingfactory 9y ago
You have a root component. Run the interval within that component where you have access to state.
- bendavis381 9y agoThat's essentially redux: root state.
- badthingfactory 9y agoIf that was "essentially redux", redux would have no reason for existence.
- RussianCow 9y agoExcept for the fact that it drastically lowers the amount of manual props passing you have to do, and allows you to achieve much better separation of concerns. It is essentially Redux, only much worse the more complex your app is.
- badthingfactory 9y ago> It is essentially Redux, only much worse the more complex your app is. so... not at all like Redux then. C# is essentially Python except it has different syntax and static typing.
- RussianCow 9y agoThe entire Redux library is something like 300 lines of code, most of which is sanity checks. It is basically the same thing as having one root component handle all your state, it just adds a tiny bit of magic for convenience. If you're comparing that to using a completely different language, I encourage you to learn more about how Redux actually works, because it's really very simple.
- eropple 9y agoIt literally IS having a root component manage state. That's what the Provider class does (enables connect() to populate via a Redux store in context).
- badthingfactory 9y agoI understand Redux, have used it many times and have read the source code. I don't understand the argument that it is "basically is the same thing as having a root component handle all your state". It's that plus actions, reducers, dispatcher, middleware, and HoCs for connecting components to global state. So it's not basically the same thing at all.
- eropple 9y agoActions, the dispatcher, and reducers are effectively a few in/out functions around a thing stuffed into the React context when used by react-redux. You're way overstating things.
- Kiro 9y agoAnd if it's in a module outside the component tree?
- k__ 9y agoAs I said, my approach isn't a one size fits all. At the moment I do React-Native projects, where every app is self contained. On the Web you often have more mashup. But the approach still works for most Web UIs too, just not for all.