React: Mixins Considered Harmful
The decorator-based approach sounds interesting, but (in my understanding) it will require moving the data fetching logic away from the main component into the decorator, which also creates a level of indirection that is intransparent to the component user, and I imagine stacking several of these decorators on top of each other should provide plenty of room for unforeseen side effects as well.<p>Personally, I think almost all components should be &quot;dumb&quot;: They should just receive the stuff that they display as properties from their parent components and report changes back through callbacks. They should not perform any &quot;controller logic&quot; beyond form validation and input serialization. Only a few components at the top should be responsible for fetching and distributing resources from the backend. Typically, it should suffice to have an &quot;Application&quot; component that takes care of fetching stuff that every other component should see (e.g. data about the user), while components one level below the application should fetch stuff that is specific to the given page&#x2F;view that is being displayed.<p>Unfortunately, compared to the humble beginnings a few years ago I feel that the whole React.js stack gets more and more bloated these days. As an example, managing state through Redux requires writing actions, reducers and implementing a subscriber pattern in my components, just to fetch some data from the server. I mean, if we&#x27;re writing a version of &quot;Photoshop&quot; for the browser this level of complexity might be warranted, but in most cases we just want to fetch some JSON, display it nicely formatted to the user, let him&#x2F;her click on it and possibly send some data back. If we need 500 kB of Javascript libraries to do that while having to patch&#x2F;reinvent many other things that we took for granted before -like simple hyperlinks (I&#x27;m looking at you, react-router)-, chances are we&#x27;re doing it wrong.