3 ms·
First, I want to thank you for the deep dive into one of your grievances with React. I completely understand this wart in React, so much so, that I use it an in
by nemothekid 5y ago
First, I want to thank you for the deep dive into one of your grievances with React. I completely understand this wart in React, so much so, that I use it an interview question for frontend developers. This kind of "connecting" is where even more complexity has often reared it's head as the common "solutions" are using something like Redux. A trivial example of what you are trying to explain is like a shopping cart; where the cart exists in the header, but the button to add items to it may exist elsewhere.
That said,
>The great success of React is in enforcing a new kind of authoritarianism: it enforces doctrine by explicitly disallowing heretical code.
I don't think this is a bad thing, after all the success of Rust is also predicated on explicitly disallowing heretical code that may have been commonplace in C. Constraints lead to more maintainable code, which is ultimately what frameworks these provide. I don't think your complaint is unique to React due to the fact it's HTML that influences that hierarchal design. That said, I'm not a front-end dev, and I my exposure to UI patterns is relatively limited; so I'm looking forward to your eventual book.
- thomashop 5y agoWouldn't you just wire up Button Press -> State -> Shopping Cart View Just have the state have a function for dispatching a change to the shopping cart which is passed to the button component and pass the actual state to the shopping cart view. You can have the state live in a parent component, use redux, use context or go more hacky.
- nemothekid 5y ago>live in a parent component, use redux, use context or go more hacky. My initial reading of OP's post is that this is the "hack" he doesn't like (even Context wasn't all that encouraged in React IIRC). My amusement, however, is this is, to him, a fundamentally philosophical disagreement with the design of React