-
Notifications
You must be signed in to change notification settings - Fork 0
Homework 2 #2
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
base: master
Are you sure you want to change the base?
Homework 2 #2
Conversation
| previews: [], | ||
| searchOpts: { | ||
| maxResults: 10, | ||
| key: 'AIzaSyC1ORL6Y3zxvLLev6QHUqP8eF1hFbYo1WI', |
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.
the key is not a part of a state
| activeVideo : {} | ||
| } | ||
| this.updateSearch = this.updateSearch.bind(this); | ||
| this.getPreviews = this.getPreviews.bind(this); |
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.
you don't need to bind instance methods
|
|
||
| return ( | ||
| <div className="video-detail col-md-8"> | ||
| {console.log(linkToVideo)} |
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.
not sure you need a console.log in jsx
| import React, { Component } from "react"; | ||
| import {VideoPreview} from "./video_preview"; | ||
|
|
||
| const renderPreviews = (previews,activatePreview) => { |
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.
just a prototype method is fine, an additional function is a bit overhead
| render () { | ||
| const preview = this.props.preview; | ||
| return ( | ||
| <li className="list-group-item" onClick={() => this.props.activatePreview(preview)}> |
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's better to create an instance method which would be responsible for click instead of doing it inside JSX.
You current JSX would create new function every time if components renders
| <iframe title="random" src={linkToVideo}/> | ||
| </div> | ||
| <div className="details"> | ||
| <div>{video.title}</div> |
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.
please extract title, description, id from props
| super(); | ||
| this.state = { | ||
| previews: [], | ||
| searchOpts: { |
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.
searchOpts is not a part of a state, they could be static and refers only to API
| searchOpts: { | ||
| maxResults: 10, | ||
| key: 'AIzaSyC1ORL6Y3zxvLLev6QHUqP8eF1hFbYo1WI', | ||
| videoEmbeddable: true, |
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.
I haven't found any place where you use videoEmbeddable, is it required ?
| key: 'AIzaSyC1ORL6Y3zxvLLev6QHUqP8eF1hFbYo1WI', | ||
| videoEmbeddable: true, | ||
|
|
||
| type:"video" |
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.
same as above
| } | ||
|
|
||
| getPreviews = () => { | ||
| Search(this.state.searchText, this.state.searchOpts, (err, results) => { |
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.
I would split request and request handlers to different methods, but it's okey.
работает Utube