Archived
function withComments(WrappedComponent){
class CommentsFetcher extends React.Component{
constructor(props){
super(props);
this.state={
comments:[],
isFetchingComments: true,
commentsError: null,
};
}
componentDidMount(){
fetchComments()
.then((comments)=>this.setState({comments, isFetchingComments: false}))
.catch((error)=>this.setState({isFetchingComments: false, commentsError: error}));
}
render(){
return<WrappedComponent{... this.props}{... this.state}/>;
}
}
return CommentsFetcher;
}
Check the statement(s) that are true:
Author: Victor SabatierStatus: ArchivedQuestion passed 1062 times
2
Community EvaluationsNo one has reviewed this question yet, be the first!
17
Write a React component as a function27
Write the missing code to render the children of the UserProfile component.10
Write a React component that displays the sum of two numbers14
Save the state used to display the selected page in a React component.34
Write the non-JSX equivalent of the following code:11
Use useCallback to optimize rendering in React18
Call a function on the first render of a React component