![](/img/trans.png)
[英]React functional component TypeError: Cannot read property 'props' of undefined
[英]I'm getting TypeError: Cannot set property 'props' of undefined while trying to use props inside functional component in React?
这是应用程序组件:
import React, {Component} from 'react';
import Title from './components/Title';
class App extends Component() {
render(){
return(
<div>
<Title title='Photowall' />
</div>
)
}
}
export default App;
这是标题组件:
import React from 'react';
const Title= (props) => {
return(
<h1> {props.title} </h1>
)
}
export default Title;
我不知道我做错了什么,但这给了我一个错误 TypeError: Cannot set property 'props' of undefined
叹,
我不应该使用
class App extends Component()
反而,
class App extends Component
现在可以使用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.