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);
|
console.log('updated:', updated);
|
||||||
|
|
||||||
const { stories } = result;
|
const { stories } = result;
|
||||||
if (stories) {
|
|
||||||
stories.sort((a, b) => b.date - a.date);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({ stories });
|
this.setState({ stories });
|
||||||
localStorage.setItem('stories', JSON.stringify(stories));
|
localStorage.setItem('stories', JSON.stringify(stories));
|
||||||
|
|
||||||
|
@ -54,6 +50,10 @@ class Feed extends React.Component {
|
||||||
const stories = this.state.stories;
|
const stories = this.state.stories;
|
||||||
const error = this.state.error;
|
const error = this.state.error;
|
||||||
|
|
||||||
|
if (stories) {
|
||||||
|
stories.sort((a, b) => b.date - a.date);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='container'>
|
<div className='container'>
|
||||||
<Helmet>
|
<Helmet>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user