4 ms·
A lot of those old paradigms you've mentioned have just evolved into new forms, based on lessons learned. Moving from mixins to HOCs, for example, should be rel
by testbot123 6y ago
A lot of those old paradigms you've mentioned have just evolved into new forms, based on lessons learned. Moving from mixins to HOCs, for example, should be relatively easy because they're based on the same concepts [1] and are solving the same types of problems.
Another example: React.memo does not replace shouldComponentUpdate, nor is it more idiomatic. React.memo is for /function components/, while shouldComponentUpdate is for class components [2].
Another example: the community wanted a more flexible way of using function components with state, and a way to decouple unrelated state: enter hooks. They're not necessarily more idiomatic, but instead provide an alternate way of structuring components and application logic that fits more use-cases.
New context is the same as old context. Hooks just enable another way of interacting with context.
[1] https://medium.com/@dan_abramov/mixins-are-dead-long-live-higher-order-components-94a0d2f9e750 https://medium.com/@dan_abramov/mixins-are-dead-long-live-hi...
[2] https://reactjs.org/blog/2018/10/23/react-v-16-6.html#reactmemo https://reactjs.org/blog/2018/10/23/react-v-16-6.html#reactm...
- lhorie 6y ago> have just evolved into new forms, based on lessons learned Well, yeah, that's what churn means. Consider, for example, that Vue and Angular have more or less stayed the same in terms of how people are supposed to write idiomatic code. The vue equivalent of hooks is very much seen as yet another option on equal footing (if not slightly derided as bandwagoning) since the old ways are just as expressive. When I hear people talking about React hooks, it's certainly not framed in terms of "oh it's just a different way of writing the same thing", but rather "oh it's better because it solves a bunch of issues w/ older idioms". Another example, Mithril.js adopted element-level lifecycle methods (similar to Inferno et al) and the community largely thinks hooks are unnecessary - the last major bump was only major due to obscure semantic technicalities rather than introducing major ways of writing code (Vue is another great example that similar in this regard as well)