const MyContainer = (WrappedComponent) =>
class extends WrappedComponent {
render() {
return
HOC DEBUGGER COMPONENT
props
{JSON.stringify(this.props, null, 2)}
state
{JSON.stringify(this.state, null, 2)}
{super.render()}
}
}
上面的代码中为什么this指向的是WrappedComponent这个组件
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
this指向当前上下文环境,此时的上下文环境是WrappedComponent这个组件
this指向当前上下文环境 的这里的this 应该是指向MyContainer的示例 ,也就是WrappedComponent的子类的示例