this.handleCommentDisLike = this.handleCommentDisLike.bind(this);
}
+ componentDidUpdate(prevProps: CommentNodeProps) {
+ if (
+ prevProps.node.comment.my_vote !== this.props.node.comment.my_vote ||
+ this.state.score !== this.props.node.comment.score
+ ) {
+ this.setState({
+ my_vote: this.props.node.comment.my_vote,
+ score: this.props.node.comment.score,
+ });
+ }
+ }
+
render() {
let node = this.props.node;
return (
)}
</h5>
{this.selects()}
- {this.state.posts && <PostListings posts={this.state.posts} />}
+ <PostListings posts={this.state.posts} />
{this.paginator()}
</div>
<div class="col-12 col-md-4">
this.setState(this.state);
} else if (op == UserOperation.GetPosts) {
let res: GetPostsResponse = msg;
-
- // This is needed to refresh the view
- this.state.posts = undefined;
- this.setState(this.state);
-
this.state.posts = res.posts;
this.state.loading = false;
this.setState(this.state);
) : (
<div>
{this.selects()}
- {this.state.posts && (
- <PostListings posts={this.state.posts} showCommunity />
- )}
+ <PostListings posts={this.state.posts} showCommunity />
{this.paginator()}
</div>
)}
this.setState(this.state);
} else if (op == UserOperation.GetPosts) {
let res: GetPostsResponse = msg;
-
- // This is needed to refresh the view
- this.state.posts = undefined;
- this.setState(this.state);
-
this.state.posts = res.posts;
this.state.loading = false;
this.setState(this.state);
this.handleEditCancel = this.handleEditCancel.bind(this);
}
+ componentDidUpdate(prevProps: PostListingProps) {
+ if (prevProps.post.my_vote !== this.props.post.my_vote) {
+ this.setState({
+ my_vote: this.props.post.my_vote,
+ score: this.props.post.score,
+ });
+ }
+ }
+
render() {
return (
<div class="row">