On this part the user gets to comment on posts. After it gets checked on server side and the data is recieved, I try to change the this.state.comments value. and so it's done. But the problem is, it is not changing the comment section on component.
I have read the previous questions about rerendering so please don't mark as duplicate. Below is the code:
$.post("requests.php", {
requestKey: 'newComment',
commenterUser: commenterUser,
commenterEmail: commenterEmail,
theComment: theComment,
pnum: pnum}, function(data, status, xhr){
if(status == 'success'){
if(data == 'commented'){
this.setState({
comments: data
})
}else{
}
}
});
The data received is all the comments related to the post and the comments section is a place where all the comments are shown.