6 ms·
This article fails to understand what components are in React. They are the building blocks for every aspect of an application. My data stores are components,
by pcmaffey 9y ago
This article fails to understand what components are in React. They are the building blocks for every aspect of an application. My data stores are components, my views are components, my styles are components.
The author obviously comes from an MVC background where a component is one specific aspect of an application, and enabling it to do all these other things seems sacrosanct. But they've got it backwards.
Think of a React component on the same level as a function: we design our functions as purely as we can, but it's not the function's fault if it's written poorly.
- jraines 9y agoI think it's more of an argument against such an understanding of a component, similar to the view that too much was packed into jQuery add-ons.
- divs1210 9y agoThe author also mentions why they see this property of React as a problem. This is just like earlier versions of Java which didnt have enums or lambdas, but used classes for everything. See what's happened now.
- lilactown 9y agoEDIT: I also think you've severely misinterpreted the article; re-frame (the library/framework that builds on top of reagent, which is a wrapper for React in clojurescript) is basically Redux's suave older brother IMO. [EDIT: Regarding "everything is a component"] And this is a weakness. If everything is a component, everything is tied to the React library/ecosystem. It would be better to treat everything as a primitive - like, say, a function. My data stores are functions (closures), my styles are functions that return data structures, my views are functions that return components. IMO the craze that struck a lot of the React ecosystem (everything's a component! State is a component! Routes are components! Side effects are components!) is dying down and people are realizing that it's better to stick to things that are much simpler and has first-class support from the language. Tying yourself to React (or any one technology) fundamentally limits your capabilities and expressiveness, and also makes your software very brittle. This is why, IMHO, most JavaScript devs actually would be much happier writing in Clojure(Script). The language provides first-class support for so many things that JS devs have to reach to libraries and frameworks for, e.g. immutability, CSP, pattern matching, and actual functional constructs like transducers.