There is so much written on this subject, so I’ll just try to briefly explain the concept and how it relates to Redux.
HOC ( "" ). , . : , , ..
: , . .
:
function hoc(WrappedComponent) {
return class HOC extends WrappedComponent {
render() {
return super.render();
}
}
}
:
function hoc(WrappedComponent) {
return class HOC extends React.Component {
render() {
return (<WrappedComponent {...this.props} extraProp={1} />)
}
}
}
, , :
function hoc(WrappedComponent) {
return (props) => (<WrappedComponent {...props} extraProp={1} />);
}
.
Redux, Redux .
connect() HOC, ( ). .
( "" ) .
, : Post , HOC connect() PostContainer.