componentWillMount

Tell us what’s happening:
These methods are considered legacy and you should avoid them in new code

Your code so far


class MyComponent extends React.Component {
constructor(props) {
  super(props);
}
componentWillMount() {
  // Change code below this line

  // Change code above this line
}
render() {
  return <div />
}
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36.

Challenge: Use the Lifecycle Method componentWillMount

Link to the challenge:

You are right. The course hints at this with the same link you posted (https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html). Probably someone should update this part of the course to say “this is a legacy feature of React, you can skip over this”

I still think it is good to have it - there is a lot of legacy code that will still have it for some time.

Yes, maybe it should say “This is an old feature of React that they recommend is not used for new code that you write. The reasons are mentioned here (link to docs…). We include this lesson so that you know how this works when you see code other people have written using componentWillMount in their projects.”

I’m not so great at phrasing these things but hopefully that’s the gist!

1 Like

I would consider most of the React curriculum legacy at this point. Not saying you shouldn’t know about it, just that it isn’t exactly the most up-to-date course on React.

1 Like

Yeah, it’s changed a lot. A lot of places don’t even use class components anymore.

I do not think skipping it could be a good idea but somehow finding article about async rendering that is dated after 2018 is really hard
What happened after 2018??