Ravenous possible error due to react.js version change?

So I reached ravenous part 3 and stumbled upon this on step 16:

" In App.js , add a method called searchYelp() in the class declaration of the App component. (Place it above the render() method.)"

When I went to app.js in my project I noticed my code looks like this:

function App() {

  return (

    <div className="App">

      <h1>ravenous</h1>

      <SearchBar />

      <BusinessList businesses={businesses} />

    </div>

  );

}

So I notice there’s no app class declaration and I went back to all the previous steps to see if I was asked to do that but I wasn’t, in fact it appears that the codecademy lessons expected my code to look like this since I initiated my react app from the beginning:

class App extends React.Component {
  render() {
    return (
      <div className="App">
        <h1>ravenous</h1>
        <SearchBar />
        <BusinessList />
      </div>
    );
  }
}

So I’m thinking react has had some kind of version change where app is created as a function declaration instead of a class declaration but I’m not entirely sure (i’ve stumbled upon another issue where when you write super(props) super is “deprecated” and apparently is due to some recent change in react). I would like to know if in fact this is the case and if so then please be aware of this issue.

Best regards.

Hi.

I think you’ve pretty much summed it up correctly yourself.

When you create a new react app it has a basic function in the app.js code. I believe in the solution video of this project or one of the others the trainer actually mentions this and says that we will have to refactor the code to create the class instead. I don’t know how react used to initialise as I have only been using it for a month or two but I guess it must have changed.

Regarding the super(props) strikethrough, it’s become an issue in the past weeks and as you say is a result of the react legacy API being deprecated. I contacted codecademy support and they said they are working on new React lessons to reflect the latest working practices. They intend to have them released by the end of the month.

1 Like

I haven’t watched the video but I’m pretty sure it’s not specified anywhere else. Glad to know they’re already working on it though, thanks for your reply.

1 Like