-
Notifications
You must be signed in to change notification settings - Fork 13
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
HT4 #41
base: master
Are you sure you want to change the base?
HT4 #41
Conversation
(should create and add users id)
@@ -50,8 +51,8 @@ Product.propTypes = { | |||
}; | |||
|
|||
const mapStateToProps = (state, ownProps) => ({ | |||
amount: state.order[ownProps.id] || 0, | |||
product: state.products[ownProps.id], | |||
amount: orderSelector(state)[ownProps.id] || 0, |
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.
лучше сразу делать селекторы, которые принимаю и стейт и пропы - orderSelector(state, ownProps) чтобы менять потом в компоненте при изменении структуры данных
|
||
const averageRating = useMemo(() => { | ||
const total = reviews.reduce((acc, { rating }) => acc + rating, 0); | ||
const total = reviews.reduce( |
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 Restaurants = ({ restaurants }) => { | ||
const tabs = restaurants.map((restaurant) => ({ | ||
const tabs = Object.values(restaurants).map((restaurant) => ({ |
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.
Object. values(restaurants) должно быть в селекторах и мемоизировано
}; | ||
|
||
const mapStateToProps = (state, ownProps) => { | ||
const review = reviewsSelector(state)[ownProps.id]; |
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 newReviewId = uuidv4(); | ||
const newUserId = uuidv4(); | ||
|
||
action.payload.values = { |
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.
не стоит мутировать action, лучше создать новый
...restaurants, | ||
[activeRestaurantId]: { | ||
...activeRestaurantData, | ||
...activeRestaurantData.reviews.push(addedNewReview), |
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.
это все равно мутация reviews по ссылке, такого делать нельзя
No description provided.