Skip to content Skip to sidebar Skip to footer

React Cannot Set Property Of Props Of Undefined

I have a simple component like this import { Component } from 'react' export default class SearchList extends Component(){ constructor(props){ super(props); }

Solution 1:

When you write a react component extending React.Component you don't need the extra () after React.Component

Use this

export default class SearchList extends Component{
    constructor(props){
        super(props);
    }
    render(){
        const { placeholder } = this.props;
        return(
            <div className="searchList">
                <input type="text" placeholder={placeholder}/>
                <button>Search</button>
            </div>
        )
    }
}

Post a Comment for "React Cannot Set Property Of Props Of Undefined"