属性代理
import React, { Component } from 'react'
export default function (WrappedComponent) {
return class hocHistory extends Component {
componentDidMount() {
console.log(this.state);
}
render() {
const newProps = {
test:'新属性'
}
return <WrappedComponent {...this.props} {...newProps}/>
}
}
}
反向继承
export default function (WrappedComponent) { return class hocHistory extends WrappedComponent { render() { return super.render(); } } }