move sort to render.
This commit is contained in:
parent
4f90671cec
commit
0567cdfd9b
|
@ -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 (
|
||||
<div className='container'>
|
||||
<Helmet>
|
||||
|
|
Loading…
Reference in New Issue
Block a user