在这个例子中,我有这个 response 类:
class MyDiv extends React.component
constructor(){
this.state={sampleState:'hello world'}
}
render(){
return <div>{this.state.sampleState}
}
}
问题是我能不能给它加上反应挂钩。我知道 React-Hooks 是 React 类风格的替代品。但是如果我希望慢慢地迁移到 React hook,我可以在 Class 中添加有用的钩子吗?