Use the Lifecycle Method componentDidMount

Tell us what’s happening:
I cant understand what was supposed to go in the code there
can ayone help?

Your code so far


class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      activeUsers: null
    };
  }
  componentDidMount() {
    setTimeout( () => {
      this.setState({
        activeUsers: 1273
      });
    }, 2500);
  }
  render() {
    return (
      <div>
        <h1>Active Users: {/* code to be written*/ }</h1>
      </div>
    );
  }
};

Your browser information:

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

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

Hint:
You want to visualize the data stored in the variable activeUsers from the state

thanks
but i think i don’t understand how to pass it
could you be more specific?

You’re asked to display the variable activeUsers - you can recall it from the state.
If you don’t know how to recall a variable available into the store i suggest yo have a look at this challenge: FCC - Create a stateful component

1 Like

Thank you Layer
solved the challenge

1 Like

you should write: {this.state.activeUsers}

I kinda wish that every “get hint” had a reference to the appropriate lesson like this just did. It helped me solve this problem in 2seconds on my own.