简体   繁体   中英

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

Sigh,

I shouldn't be using

class App extends Component()

but rather,

class App extends Component

It works now

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM