-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react-cinema #17
base: master
Are you sure you want to change the base?
react-cinema #17
Conversation
|
||
this.setState({ | ||
page: this.state.page + 1 | ||
}, () => this.fetchMovies(this.state.userSearch,this.setState.page)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to access page from state you need to use this.state.page
rather than this.setState.page
. setState
is a method used to change state rather than get values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it would be better to avoid using the setState callback here, by calculating next page number, storing it in a variable and then you can pass both to setState and fetchMovies
handlePrevClick(){ | ||
this.setState({ | ||
page: this.state.page - 1 | ||
},() => this.fetchMovies(this.state.userSearch, this.setState.page)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above
@@ -0,0 +1,13 @@ | |||
import React from 'react'; | |||
|
|||
class Button extends React.Component { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this component is not used anywhere
fetch(`http://www.omdbapi.com/?apikey=8d5ab09&i=${this.props.movie.imdbID}`) | ||
.then(response => response.json()) | ||
.then(body => | ||
this.setState({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to store the returned movie object in state and generate the strings to display to user in render method
class Search extends React.Component { | ||
constructor(){ | ||
super() | ||
this.state = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the search query is stored both in Search
and App
. It would better to avoid state duplication and pass the search query down from App
to Search
Good work. A few bits could be tidied up. Take a look at the comments for details. |
No description provided.