-
Notifications
You must be signed in to change notification settings - Fork 26
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
Misnik ht 3 #46
base: master
Are you sure you want to change the base?
Misnik ht 3 #46
Conversation
|
||
function Basket ({ restaurants, orderMap, amount }) { | ||
|
||
const menu = restaurants.map((item) => item.menu).reduce((previousValue, currentValue) => previousValue.concat(currentValue)) |
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.
это вычисление лучше мемоизировать
const newOrderMap = orderMap; | ||
let allSum = 0; | ||
|
||
const products = Object.entries(newOrderMap).filter(item => item[1] > 0).map((item) => { |
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.
и в целом все эти вычисления можно вынести в mapStateToProps
deleteItem: () => dispatch(deleteItem(props.id)) | ||
}) | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(BasketItem) |
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.
если mapStateToProps не нужен, то можно null передать
No description provided.