-
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
uuid, normalized reviews, restaurant, users reducer #54
base: master
Are you sure you want to change the base?
Conversation
export default connect((state, props) => { | ||
return { | ||
allReviews: reviewsSelector(state), | ||
currentReviews: props.restaurant.reviews.map(item => reviewsSelector(state)[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.
это все лучше написать через один селектор currentReviewsSelector(state, props)
}))(ReviewForm); | ||
export default connect(null, (dispatch, state, props ) => ({ | ||
onSubmit: (values, name) => { | ||
dispatch(addReview(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.
это лучше делать через один екшен, покажу на своей домашке и на разборе расскажу в чем может быть проблема такого подхода
const userID = uuidv4(); | ||
const reviewID = uuidv4(); | ||
console.log(action.id) | ||
next({'type': ADD_USER, 'user': { ...action.user, 'id': userID }}); |
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.
это не будет работать корректно, т.к. эти next вызываются для любого екшена в нашем приложении, в т.ч. INCREMENT/DECREMENT
@@ -31,4 +35,12 @@ Review.defaultProps = { | |||
user: 'Anonymous', | |||
}; | |||
|
|||
export default Review; | |||
export default connect((state, props) => { | |||
return { |
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.
все эти вычисления можно вынести в один селектор
No description provided.