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