Jamming super deprecated

Hi everyone,

I have a problem with super(props). When I write props the word cross up and appear this message.

class App extends React.Component {

constructor(props){

super(props);

this.state = {

  searchResults: [{name:'name1', artist:'artist1', album:'album1', id:1}, {name:'name2', artist:'artist2', album:'album2', id:2},{name:'name3', artist:'artist3', album:'album3', id:3}] 

}

}

render () {

return (

  <div>

  <h1>Ja<span className="highlight">mmm</span>ing</h1>

  <div className="App">

  <SearchBar/>

  <div className="App-playlist">

  <SearchResults searchResults={this.state.searchResults}/>

  <Playlist />

  </div>

  </div>

  </div>

);

}

}

Thank you!!!

I think the constructor isn’t necessary. You can just do

class App extends React.Component {


this.state = {

  searchResults: [{name:'name1', artist:'artist1', album:'album1', id:1}, {name:'name2', artist:'artist2', album:'album2', id:2},{name:'name3', artist:'artist3', album:'album3', id:3}] 

}
render () {

return (

  <div>

  <h1>Ja<span className="highlight">mmm</span>ing</h1>

  <div className="App">

  <SearchBar/>

  <div className="App-playlist">

  <SearchResults searchResults={this.state.searchResults}/>

  <Playlist />

  </div>

  </div>

  </div>

);

}

}

and it will work but you won’t have access to props anymore.

I just checked my project file and this has appeared on there too. It was not there a few weeks ago when I did the project so is a new behaviour.

I followed the link given in your image which takes you to the react.org site. It basically says the method we are using (Legacy API) is being phased out and that it will only be supported up to the end of version 16 of react.

I guess the course needs to be updated to reflect current methods!

Thank you. I hope this won´t end up in a error

I raised it with the help desk and they informed me that the team are updating the React lessons now to reflect the changes. They expect the new lessons to be up by the end of the month.