Started working in the infinate scroll so it loads the next page when visible on page. This commit was under_development bugs as of now.
This commit is contained in:
@@ -129,10 +129,24 @@ 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));
|
||||||
|
console.log(responseMovieObjects)
|
||||||
|
console.log(this.state.responseMovieList)
|
||||||
|
let growingReponseMovieObjectList = this.state.responseMovieList.concat(responseMovieObjects);
|
||||||
|
this.setState({
|
||||||
|
responseMovieList: growingReponseMovieObjectList,
|
||||||
|
lastApiCallURI: uri // Save the value of the last sucessfull api call
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log(error)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@@ -216,8 +230,6 @@ class SearchRequest extends React.Component {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Updates the internal state of the query search field.
|
// Updates the internal state of the query search field.
|
||||||
updateQueryState(event){
|
updateQueryState(event){
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|||||||
Reference in New Issue
Block a user