2 ms·
Sure, but then you need to make sure they never get out of sync. If you add a "remove order" action you need to remember to decrease the sum. Really, if we're s
by repsilat 7y ago
Sure, but then you need to make sure they never get out of sync. If you add a "remove order" action you need to remember to decrease the sum. Really, if we're smart and diligent enough to be able to correctly update all the derived state after we've changed a bit of "core state", why have things like react or redux at all?
In my view, the point of them (whether you agree with them or not) is to avoid having to make those updates to derived data. Changing core state is unavoidable, but there's just a lot less that can go wrong if everything else is (seemingly) re-derived from scratch whenever those changes happen. It's the "turn it off and turn it on again" approach to updating derived state.