by eric_b · 8y ago · 0 comments
Of the big JS frameworks that are popular at the moment, I think the React team is doing the best job of balancing new features with minimizing developer pain and breaking changes.
If I had one thing negative to say about this release, it's that I think the forwardRef is maybe moving in the wrong direction a bit. In my experience, higher order components should be the exception, not the rule. They are a neat way to provide some functionality that is otherwise difficult, but their cognitive and maintenance overhead are high. If it stops at forwardRef, no big deal, but I am not sure HOCs are something that deserve explicit API support (and the additional surface area that entails)
React has a great deprecation strategy. Their general philosophy is "if you can use version X with no warnings, you should be able to use version X+1 with no changes to your app."
I'm happy to see a thoughtful solution. There are some things you just can't do with React alone (like listen for PointerEvents).
https://developer.mozilla.org/en-US/docs/Web/API/PointerEven...
If anything, I think the new context API (and even forwardRef itself) are endorsements of the render prop pattern more than of HOCs. :)
This just isn’t true. Abstracting form logic. Request logic. Anything else you use across your app. Connect in redux. There are hundreds of good reasons to have a higher order component.
It makes testing easy. Test your request logic in one place, anything that uses it is now a stateless component, and testing it is trivial.
Request logic doesn’t belong in a render function. Routing definitions don’t belong in a render function and neither does abstract form logic.