-
Notifications
You must be signed in to change notification settings - Fork 49k
Description
(unsure if this is the right place, so trying it out)
I've noticed that the new React Hooks feature is aiming at providing an alternative composition pattern to HOC and render functions, but I believe that many of the use cases solved by HOC (at the framework level) cannot currently be addressed by the new hooks API.
Specifically, there is not way to incorporate React Hooks with React.memo. Unless I am incorrect, this means that any system that would like to implement optimisations based on external context, such as the react-redux connect
function (that uses mapStateToProps
to implement an efficient shouldComponentUpdate
) will still need to rely on a HOC/render-prop to automate this optimisation.
The reason I am bringing this up is because one of the main benefits stated in the documentation is to reduce framework level use of HOC that "pollute" the tree, of which the react-redux connect HOC is probably the most prevalent use case.
Additionally redux (and useRedux
) are specifically brought up as an exemplary use case, although with the current system it will cause large optimisation issues (since with no optimised shouldComponentUpdate
, every "connected" component will re-render on every state change).
(Although this might fit into the documentation repo, this is a discussion / opinion and I do not feel it is a "mistake" that I should report, but rather a discussion on importance).
An example solution for this could be if there was a way to use contexts in React.memo
(which unless I'm incorrect only have access to props
and prevProps
)