Tanbir
1
Ohhhhh what I shoud do with that code? 
class MyComponent extends React.Component {
constructor(props) {
super(props);
}
componentWillMount() {
// change code below this line
// change code above this line
}
render() {
return <div />
}
};
It’s quite simple. The instruction says
Log something to the console within componentWillMount()
.
Tanbir
3
how and where i will call this componentWillMount(). i don’t understand
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
activeUsers: null
};
}
componentDidMount() {
setTimeout( () => {
this.setState({
activeUsers: 5315
});
}, 2500);
console.log(componentWillMount);
}
render() {
return (
<div>
<h1>Active Users: {this.state.activeUsers}</h1>
</div>
);
}
};
Reset your code. Then do a simple log like console.log(“Hello World”) inside of here.
componentWillMount() {
// change code below this line
// change code above this line
}
1 Like