Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sphariab
Copy link

No description provided.

export default connect((state, props) => {
return {
allReviews: reviewsSelector(state),
currentReviews: props.restaurant.reviews.map(item => reviewsSelector(state)[item])
Copy link
Owner

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))
Copy link
Owner

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 }});
Copy link
Owner

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 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

все эти вычисления можно вынести в один селектор

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants