Skip to content
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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

react-cinema #17

wants to merge 9 commits into from

Conversation

jay9044
Copy link

@jay9044 jay9044 commented Oct 3, 2018

No description provided.


this.setState({
page: this.state.page + 1
}, () => this.fetchMovies(this.state.userSearch,this.setState.page))
Copy link
Contributor

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

Copy link
Contributor

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))
Copy link
Contributor

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 {
Copy link
Contributor

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:https://www.omdbapi.com/?apikey=8d5ab09&i=${this.props.movie.imdbID}`)
.then(response => response.json())
.then(body =>
this.setState({
Copy link
Contributor

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 = {
Copy link
Contributor

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

@dmitrigrabov
Copy link
Contributor

Good work. A few bits could be tidied up. Take a look at the comments for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants