Hard
class Time extends React.Component{
constructor(props){
super(props);
this.state={order:[]};
}
componentWillMount(){
setTimeout(()=>{
this.setState({order: this.state.order.concat(1)});
}, 1000);
this.setState({order: this.state.order.concat(2)});
}
componentDidMount(){
// httpCall is an asychronous dummy function
// It can take between 500ms and 1500ms
httpCall('/some/api'). then(()=>this.setState({order: this.state.order.concat(3)}));
}
render(){
return(
<div>
{this.state.order.join(',')}
</div>
);
}
}
What does this component display?
Check the possible answer(s):
Author: Victor SabatierStatus: PublishedQuestion passed 1527 times
Edit
1
Community EvaluationsNo one has reviewed this question yet, be the first!
6
Write a React function that fetches comments and passes them to a component.7
How to submit a form in React3
Write the missing code to render the children of the UserProfile component.7
Improve this React component so that it displays "Green" by default.4
Fix the following React component: Scroller3
Write a React component as a function7
Optimize a React component by implementing shouldComponentUpdate