Hard
We want to optimize this component by implementing shouldComponentUpdate
:
class Comments extends React.Component{
constructor(props){
super(props);
}
shouldComponentUpdate(nextProps, nextState){/* MISSING CODE*/}
render(){
return(
<div>
{this.props.comments.map((comment, i)=><p key={i}>{comment}</p>)}
</div>
);
}
}
Comments.propTypes={
comments: PropTypes.arrayOf(PropTypes.string).isRequired
};
Check the valid optimization(s):
Author: Victor SabatierStatus: PublishedQuestion passed 1455 times
Edit
7
Community EvaluationsNo one has reviewed this question yet, be the first!
3
Fix the following React component: Scroller7
Improve this React component so that it displays "Green" by default.6
Write a React function that fetches comments and passes them to a component.6
How to submit a form in React2
Write the missing code to render the children of the UserProfile component.2
Fix the following React component:3
Write a React component as a function