Use the Lifecycle Method componentWillMount-not passing in codepen

Tell us what’s happening:

I passed in fcc but not getting the output in codepen despite inserting everything behind the hood in codepen. wonder why?my codepen link is : []

Your code so far

class MyComponent extends React.Component {
  constructor(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/76.0.3809.132 Safari/537.36.

Link to the challenge:

The console.log actually runs. It’s printing the component definition itself in the console.

1 Like

Hi, on a note not related to the challenge, but rather for future reference, I advise you to not use componentWillMount because it has been deprecated and it will be removed from the future versions of React (if it hasn’t been removed already).
Whatever you used to put before in the componentWillMount, now you should put them either in the constructor or in the definition of the componentDidMount method.
Take a look at Vladimir K.'s answer here on Stack Overflow.
The question is about React Native, but it applies to React as well.

1 Like