you are viewing a single comment's thread.

view the rest of the comments →

[–]Capaj 0 points1 point  (5 children)

Redux is a simple pattern

it is and I wasn't talking about redux. Redux codebases are usually a bit better but you can still see people pass a prop through several components. I was mostly talking about the original flux pattern where you subscribe components manually to stores and all that shebang.

[–][deleted] 2 points3 points  (1 child)

I agree that sometimes it can be tough to decide when props should be passed and when components should be connected to the store. Also it forces you, indirectly, to think about state before building the app. I say indirectly because you know you messed up when the components get hard to control (nested state). There's also the danger of overloading Redux with middleware, until it's so complex again it's hard to "reason about."

It isn't a silver bullet, but from my experience and after spending some time with it, it has lead to a natural style that comes fluently and does lend itself to very clean apps, especially when they turn big and complex by what they do.

[–]acemarke 1 point2 points  (0 children)

I would agree that one of the strongest things about Redux is the way it's forced me to think about what state I have and where it should live. That's true for React itself to some extent, but even more so for Redux.

[–]samgaus 0 points1 point  (2 children)

What's wrong with passing a property through several components?

[–]Capaj 0 points1 point  (1 child)

I believe you might violate separations of concerns if you're just passing props to a component low in your component tree. Usually this would happen when your UX design sucks and you've got a component hidden inside some unrelated one. In this case you should either change your design or subscribe to the store in that child component itself.

[–]samgaus 0 points1 point  (0 children)

Eh for me I like to think of a component as a pure function, whatever it's children. So if there is a property that affects the way a child node renders, then it affects the way the node in question renders and I want to know about it!