4 ms·
The ReactJS community is not simplifying annoying problems. The JavaScript community did that. The ReactJS community is quite literally re(!)-implementing promi
by mikojan 5y ago
The ReactJS community is not simplifying annoying problems. The JavaScript community did that. The ReactJS community is quite literally re(!)-implementing promises here to make them work with a purported library(!).
This is insane. You shouldn't need to download useConsole from npm.
- phailhaus 5y ago> The ReactJS community is quite literally re(!)-implementing promises here to make them work with a purported library(!). What? I don't think you understand hooks very well. You can already use promises with hooks by creating them and then calling `setState` however you want in the callbacks to deal with pending/success/error. It's such a common pattern that the community has developed a `usePromise` hook that abstracts away all that logic for you, meaning that you can treat any promise as a stateless value to be consumed by your components, one that will automatically manage its state for you and guarantee your UI is consistent without any additional effort. I never have to deal with managing asynchronous state ever again! That's what a good library does: allow you to build reusable components that abstract away complexity. Hooks let you abstract away state management, the bane of UI development. I can tell you from experience dating back to Backbone and Marionette that it has never been so easy to deal with async state before. Coupled with Typescript, I also get the guarantee that I've accounted for every possible case (success, pending, error). It's a zero-cost abstraction. What's your experience with hooks?
- mikojan 5y agoI understand modern JavaScript development is a giant leap forwards compared to JavaScript development 10 years ago. Nobody is arguing with that. Your last statement is completely wrong, though. ReactJS/hooks are not zero-cost abstractions. They impose a cost both in terms of real performance as well as cognitive complexity. And when you run into performance issues you're almost certainly confronted with this pattern of escalation (assuming you've done nothing wrong): 1. Litter your Code with calls to useMemo/useCallback. 2. Re-evaluate your business needs because you've exhausted the hooks "primitive". 3. Iteratively and painstakingly force more and more logic out of ReactJS' scope until you've met your benchmark targets. Following along quickly requires intricate knowledge of poorly documented but overwhelmingly complex ReactJS internals alongside(!) whatever knowledge of JavaScript internals is required. You have to have and process 2 complex, unique and outright byzantine models in your mind simultaneously. Compare this to Angular(!) which lets you use standard web APIs, additionally exposes useful standard(!) primitives, and(!) provides you with straight-forward(!) opt-out mechanisms. Yet here we are, quite literally downloading useInterval from npm 40,000 times a week.
- phailhaus 5y agoI think this should lead you to re-evaluate your assumptions about hooks, because there is a reason why React has blown Angular out of the water. The reactive hooks model of UI development is successful because it allows you to write almost any component as a stateless function with well-defined side-effects. Yes, it requires a different way of writing them, but it's worth it for complex applications. The fact that hooks like usePromise and useInterval can be trivially written on top of standard web APIs and guarantee that your component hierarchy will update consistently without dealing with internal state is a groundbreaking achievement. I think you are focusing too much on the fact that hooks like usePromise exist, instead of on what they enable. Have you ever used usePromise, and seen how it turns a stateful object into a stateless one? It has never been so easy to encapsulate asynchronous state.
- mikojan 5y ago> ...there is a reason why React has blown Angular out of the water. - The ensuing paragraph suggests you are conflating Angular with AngularJS. Angular is build on top of proper, standard FRP and stream processing primitives. It is "reactive". - Angular is in widespread use in the enterprise world. - The reason ReactJS is much more prevalent everywhere else is it has no barrier of entry. None at all. This, however, is irrelevant with regards to the issue I am raising. I am complaining about the complexity ReactJS dumps on working professionals. - I am not advertising Angular. I am telling you that EVEN Angular manages to suck less. > The fact that hooks like usePromise and useInterval can be trivially written on top of standard web APIs ... Again, not: "can". "Must"!!