Conversation
| @@ -0,0 +1,69 @@ | |||
| import React, {Component} from 'react'; | |||
There was a problem hiding this comment.
the file should be named with hyphen instead of underscore
the file name should refer component it's exporting
admin-page.js -> class AdminPage
| } | ||
|
|
||
| render() { | ||
| const items = this.props.items; |
There was a problem hiding this comment.
please use object destruction
|
|
||
| render() { | ||
| const items = this.props.items; | ||
| const returnListOfItems = (items) => { |
There was a problem hiding this comment.
you could create a method instead of re-creating function every time component re-renders
| const removeItem = () => { | ||
| this.props.removeItem(item.id); | ||
| } | ||
| return <AdminItem key={item.id} item={item} removeItem={removeItem} ></AdminItem> |
There was a problem hiding this comment.
if you not using children, please write component in short manner without closing tag
|
|
||
| export class CartItem extends Component { | ||
| render() { | ||
| const item = this.props.item; |
There was a problem hiding this comment.
please use object destruction
| const inCart = this.props.cart; | ||
| const returnListOfItems = (items) => { | ||
| return items.map((item ) => { | ||
| let inBasket = false; |
There was a problem hiding this comment.
const inBasket = inCart.includes(item.id)| if(inCart.indexOf(item.id) !== -1){ | ||
| inBasket = true; | ||
| } | ||
| const addItemToCart = () => { |
There was a problem hiding this comment.
you have to move it to a method and make a closure to store item.id
| const addItemToCart = () => { | ||
| this.props.addItemToCart(item.id); | ||
| } | ||
| return <ShopItem key={item.id} item={item} inBasket={inBasket} addItemToCart={addItemToCart} ></ShopItem> |
There was a problem hiding this comment.
please use shorthand Component notation
| const addItemToCart = () => { | ||
| this.props.addItemToCart(item.id); | ||
| } | ||
| return <ShopItem key={item.id} item={item} inBasket={inBasket} addItemToCart={addItemToCart} ></ShopItem> |
There was a problem hiding this comment.
there a lot of properties it's better to make it multiline. Or just simply use a prettier
| <div> | ||
| User | ||
| </div> | ||
| <Orders changePageToCartPage={this.props.changePageToCartPage} ></Orders> |
There was a problem hiding this comment.
shorthand notation for components
and extract all props via object destruction
Доделано прилодение из классной работы. Понадобилось много больше чем 4 часа.