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

exportdefaultclassSearchListextendsComponent{
    constructor(props){
        super(props);
    }
    render(){
        const { placeholder } = this.props;
        return(
            <divclassName="searchList"><inputtype="text"placeholder={placeholder}/><button>Search</button></div>
        )
    }
}

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