Fix empty result while having items in store
Let's initialise the state of the component will the actual number of items instead of 0
This commit is contained in:
parent
c42687ddd5
commit
15ec1bbecd
@ -15,11 +15,8 @@ const DEFAULT_ADD_EXTRA_ITEMS = 30;
|
||||
export default class ListPosters extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
items: 0,
|
||||
hasMore: false,
|
||||
};
|
||||
this.loadMore = this.loadMore.bind(this);
|
||||
this.state = this.getNextState(props);
|
||||
}
|
||||
loadMore() {
|
||||
// Nothing to do if the app is loading
|
||||
@ -35,7 +32,7 @@ export default class ListPosters extends React.Component {
|
||||
}
|
||||
getNextState(props) {
|
||||
let totalListSize = props.data.length;
|
||||
let currentListSize = this.state.items;
|
||||
let currentListSize = (this.state && this.state.items) ? this.state.items : 0;
|
||||
let nextListSize = currentListSize + DEFAULT_ADD_EXTRA_ITEMS;
|
||||
let hasMore = true;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user