Added infinate scroll to lists also.
This commit is contained in:
@@ -136,8 +136,6 @@ class SearchRequest extends React.Component {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
let responseMovieObjects = responseData.results.map(searchResultItem => this.createMovieObjects(searchResultItem));
|
let responseMovieObjects = responseData.results.map(searchResultItem => this.createMovieObjects(searchResultItem));
|
||||||
console.log(responseMovieObjects)
|
|
||||||
console.log(this.state.responseMovieList)
|
|
||||||
let growingReponseMovieObjectList = this.state.responseMovieList.concat(responseMovieObjects);
|
let growingReponseMovieObjectList = this.state.responseMovieList.concat(responseMovieObjects);
|
||||||
this.setState({
|
this.setState({
|
||||||
responseMovieList: growingReponseMovieObjectList,
|
responseMovieList: growingReponseMovieObjectList,
|
||||||
@@ -177,10 +175,19 @@ class SearchRequest extends React.Component {
|
|||||||
// mapped as a movieObject.
|
// mapped as a movieObject.
|
||||||
response.json()
|
response.json()
|
||||||
.then(responseData => {
|
.then(responseData => {
|
||||||
|
if (this.state.page === 1) {
|
||||||
this.setState({
|
this.setState({
|
||||||
responseMovieList: responseData.results.map(searchResultItem => this.createMovieObjects(searchResultItem)),
|
responseMovieList: responseData.results.map(searchResultItem => this.createMovieObjects(searchResultItem)),
|
||||||
lastApiCallURI: uri // Save the value of the last sucessfull api call
|
lastApiCallURI: uri // Save the value of the last sucessfull api call
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
let responseMovieObjects = responseData.results.map(searchResultItem => this.createMovieObjects(searchResultItem));
|
||||||
|
let growingReponseMovieObjectList = this.state.responseMovieList.concat(responseMovieObjects);
|
||||||
|
this.setState({
|
||||||
|
responseMovieList: growingReponseMovieObjectList,
|
||||||
|
lastApiCallURI: uri // Save the value of the last sucessfull api call
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user