【发布时间】:2023-03-21 06:35:01
【问题描述】:
我试图从通用类中获取函数应用程序中的“状态”对象,我收到此错误“未捕获的类型错误:无法读取未定义的属性“状态””。 代码是
class General extends Comment {
constructor() {
super();
this.state = { comments: first_comment};
}
}
const Application = () => {
return (
<div> Hello world beginner: {this.state.comments}</div>
);
};
render(<Application/>, document.getElementById('container'));
【问题讨论】:
-
每个问题问 一个 问题,而不是三个。
-
纯功能组件中没有状态。从表面上看,它甚至没有意义。在您的
Application组件中没有其他对状态的引用。你的意思是把它传递给某个地方的Application? -
现在我明白了。我已经得到答案,但感谢您重播。
标签: javascript reactjs web-deployment