Use the Lifecycle Method componentWillMount

Tell us what’s happening:
Ohhhhh what I shoud do with that 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/69.0.3497.92 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/use-the-lifecycle-method-componentwillmount

Why are you running a setTimeout function here?

All you need to do is just console.log out something for this challenge inside componentDidMount function.

Looks like you are copying and pasting from previous exercises. No need to do that.

The link to the lesson you provided only is asking you to add code to ```willMount`` method

class MyComponent extends React.Component { constructor(props) { super(props); } componentWillMount() { // change code below this line console.log() // change code above this line } render() { return <div /> } };

Iam not joking I write console.log() and the i put the Run the test and is right.I try so much codes.Thank you for your replay and you help

1 Like

The actual problem here is that the challenge asks you to “simply” log something, yet the course never ever mentioned anything about logs or consoles anywhere. So the user has to guess that out of the blue, which is not a good approach and not in line with the overall approach of freeCodeCamp.

3 Likes

Yeah it works!
Thankyou :innocent: