From 0567cdfd9bc6754c84444c0e0bd0251471dd5bf1 Mon Sep 17 00:00:00 2001 From: Jason Schwarzenberger Date: Tue, 3 Nov 2020 16:30:22 +1300 Subject: [PATCH] move sort to render. --- webclient/src/Feed.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webclient/src/Feed.js b/webclient/src/Feed.js index 40b10ec..0568b69 100644 --- a/webclient/src/Feed.js +++ b/webclient/src/Feed.js @@ -23,10 +23,6 @@ class Feed extends React.Component { console.log('updated:', updated); const { stories } = result; - if (stories) { - stories.sort((a, b) => b.date - a.date); - } - this.setState({ stories }); localStorage.setItem('stories', JSON.stringify(stories)); @@ -54,6 +50,10 @@ class Feed extends React.Component { const stories = this.state.stories; const error = this.state.error; + if (stories) { + stories.sort((a, b) => b.date - a.date); + } + return (