From f6ef651180f9901f21e0c0a7bac08de20bba70e8 Mon Sep 17 00:00:00 2001 From: JubbeArt Date: Thu, 9 Aug 2018 04:00:59 +0200 Subject: [PATCH] Fixed a bug where a Link's to prop would be undefined causing the page to crach --- src/pages/thread/index.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/pages/thread/index.js b/src/pages/thread/index.js index 6b367e8..2b77268 100644 --- a/src/pages/thread/index.js +++ b/src/pages/thread/index.js @@ -99,13 +99,12 @@ class Thread extends React.Component { } render () { - let root = this.state.post.id - let isSingleComment = false + const { subreddit, id } = this.state.post + const { commentID } = this.props.match.params + const linkToRestOfComments = `/r/${subreddit}/comments/${id}/_/` - if (this.props.match.params.commentID !== undefined) { - root = this.props.match.params.commentID - isSingleComment = true - } + const isSingleComment = commentID !== undefined + const root = isSingleComment ? commentID : id return ( @@ -120,9 +119,9 @@ class Thread extends React.Component { /> {isSingleComment && -
+
you are viewing a single comment's thread.
- view the rest of the comments + view the rest of the comments
}