Conversation
classworks/lesson-2/store/src/App.js
Outdated
| activePage: 'homePage', | ||
| inputValue: '', | ||
| newItems: [], | ||
| willBePurchased: [], |
There was a problem hiding this comment.
so optimistic naming :)
You know almost 70% declines happens at shopping-cart
classworks/lesson-2/store/src/App.js
Outdated
| isButton: false | ||
| })*/ | ||
| let item = event.target.previousElementSibling.textContent; | ||
| this.state.willBePurchased.push(item); |
There was a problem hiding this comment.
please not mutate the state
classworks/lesson-2/store/src/App.js
Outdated
| if (!this.state.inputValue) { | ||
| return; | ||
| }; | ||
| this.state.newItems.push(this.state.inputValue); |
There was a problem hiding this comment.
please do not mutate the state :(
classworks/lesson-2/store/src/App.js
Outdated
| return; | ||
| }; | ||
| this.state.newItems.push(this.state.inputValue); | ||
| this.setState({inputValue: ''}); |
There was a problem hiding this comment.
it's much better to write it that way:
const newItems = [...this.state.newItems, this.state.inputValue]
this.setState({
newItems,
inputValue: ''
})
classworks/lesson-2/store/src/App.js
Outdated
| } | ||
| /* | ||
| buyItemFromCart = (event) => { | ||
| let item = event.target.previousElementSibling.textContent; |
There was a problem hiding this comment.
Hope to see PR without commented code. If someone would try to review the code, commented parts would confuse
|
|
||
| export class OneItemBlock extends Component { | ||
| render() { | ||
|
|
| const {value} = this.props; | ||
|
|
||
| return ( | ||
| <li className="list-group-item"> |
| render() { | ||
| const {buyItem} = this.props; | ||
| return ( | ||
| <a href="#" className="btn btn-primary" onClick = {buyItem}>Buy</a> |
| import React, {Component} from 'react'; | ||
|
|
||
| export class PlainButton extends Component { | ||
| render() { |
There was a problem hiding this comment.
I think you could create 1 button for handle "success" and disable state
| return ( | ||
| <React.Fragment> | ||
| <button className="btn btn-light" disabled>Buy</button> | ||
| <h3 className="text-success">✓✓✓✓✓</h3> |
There was a problem hiding this comment.
Pretty sure such label should be passed via this.props.children.
At the moment you button is not only a button. It's Button + Icon
No description provided.