Update feed.js

to prevent books to be displayed out of order when the loading more books
This commit is contained in:
Gal Elmalah
2020-10-11 12:14:21 +03:00
committed by Vishnu Ks
parent 193f06bb21
commit e1962883f6

View File

@@ -6,8 +6,7 @@ import SortByDropdown, { FIELDS_TO_SORT_BY, compareFunctions } from './sortByDro
export default ({ data, limit }) => {
const [sortBy, setSortBy] = React.useState(FIELDS_TO_SORT_BY[0]);
const getSortedBooks = () => data.allBooksJson.edges
.slice(0, limit || data.allBooksJson.edges.length)
const getSortedBooks = () => [...data.allBooksJson.edges]
.sort(compareFunctions[sortBy]);
return (