From 2bd0b602ffdd8f991bbcd5b363ad0b0533c65e20 Mon Sep 17 00:00:00 2001 From: Nick Pegg Date: Sat, 7 Oct 2017 17:55:44 -0700 Subject: [PATCH] Display NotFound on missing posts --- src/Article.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Article.js b/src/Article.js index 7648e9a..fffb9d5 100644 --- a/src/Article.js +++ b/src/Article.js @@ -90,7 +90,8 @@ class Post extends Component { this.params = props.match.params; this.state = { - post: null + post: null, + notFound: false, } } @@ -115,6 +116,7 @@ class Post extends Component { if (!found) { console.log('post not found'); /* TODO: return 404 */ + this.setState({notFound: true}); } }); } @@ -129,6 +131,10 @@ class Post extends Component { } render() { + if (this.state.notFound) { + return + } + if (this.state.post) { return (