From 23e5b5a024df82a271bd7eff596f3f0b902d52c8 Mon Sep 17 00:00:00 2001 From: Berke Aras Date: Tue, 4 May 2021 12:34:10 +0200 Subject: [PATCH] Fix issue --- src/components/_App_CommentSection/index.jsx | 47 +++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/components/_App_CommentSection/index.jsx b/src/components/_App_CommentSection/index.jsx index b0e887a..32bd10e 100644 --- a/src/components/_App_CommentSection/index.jsx +++ b/src/components/_App_CommentSection/index.jsx @@ -1,4 +1,5 @@ import React, { useRef } from 'react' +import { BrowserRouter as Router, Switch, Route, Link, Redirect } from 'react-router-dom' import './style.scss' import { Feed, Icon, Header, Loader, Button, Comment, Form } from 'semantic-ui-react' import PropTypes from 'prop-types' @@ -47,7 +48,7 @@ class CommentSection extends React.Component { that.setState({ comments: result }) }) .catch((error) => { - console.error(error) + location.href = '/' }) } @@ -144,27 +145,31 @@ class CommentSection extends React.Component { Comments - {this.state.comments.length == 0 ? ( - Sorry. We could not find any comments. + {this.state.comments ? ( + this.state.comments.length == 0 ? ( + Sorry. We could not find any comments. + ) : ( + this.state.comments.map((comment) => { + return ( + + {comment.avatar == '' ? ( + + ) : ( + + )} + + {comment.name} + + {this.getDate(comment.created_at)} + + + + + ) + }) + ) ) : ( - this.state.comments.map((comment) => { - return ( - - {comment.avatar == '' ? ( - - ) : ( - - )} - - {comment.name} - - {this.getDate(comment.created_at)} - - - - - ) - }) + )}