DEV Community

Discussion on: Redux is half of a pattern (1/2)

 
bradtaniguchi profile image
Brad

I do find it fascinating how there are very drastic responses to this post so far I must say. Some people agree that Redux is inherently "wrong", and other argue its inherently "right".

I'm like many, waiting for part two :D

Thread Thread
 
blocka profile image
Avi Block

The main advantage is to have 1 SINGLE "ROOT" of THRUTH!

Not sure about you, but in the types of apps that I write, I can not see any advantages of having a "single source of truth". In general, the complexity is always either at the page level, not the app level (the app is essentially just a router with some small global data, and an entity cache), or within some sub components on each page.

So I don't need a "single state atom" for anything. What I do need is to manage the state transitions of those complex components. Redux does nothing for me here. XState does tons.

I suspect most people are using redux as a global entity cache, or worse...what you do to store "global" data.

Thread Thread
 
luiz0x29a profile image
Real AI

They talk about Single root of "thruth", but the elephant in the room is the insidious internal mutable state on every React component that's not pure and/or has hooks.

Wasn't the entire point of modelling state/events/transitions knowing when to do actions, like rendering the screen.

So if there was a proper way of doing virtual finite state machines, you wouldn't need react to reconcile the three, you could just go and change the DOM directly with impunity.

The DOM would be the single source of truth for the visual representation of the applications, and it wouldn't be slow because you wouldn't be randomly poking and mutating it without reason.
It would actually be faster, as it would only change precisely in "reaction" to state+events, ironic for something called "React" that doesn't react to anything, it should be called Render.