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

[ht4] normalisation fixes and review posts #65

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

Conversation

AntonNekrasov
Copy link

No description provided.

const mapStateToProps = (state, ownProps) => {
const { reviews } = ownProps.restaurant;
return {
reviews: reviews.map((id) => state.reviews[id]),
Copy link
Owner

Choose a reason for hiding this comment

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

это нужно выносить в селекторы и мемоизировать.

case SET_ACTIVE:
return action.payload;
default:
return activeRestaurant;
Copy link
Owner

Choose a reason for hiding this comment

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

теперь знание о какой ресторан активный храниться в двух местах, в этом редьюсере и в компоненте


const uuidGenerator = () => (next) => (action) => {
if (action.type === ADD_REVIEW) {
action.payload.userId = uuidv4();
Copy link
Owner

Choose a reason for hiding this comment

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

не нужно мутировать action

case ADD_REVIEW:
const { id, activeRestaurant } = action.payload;
const restaurant = restaurants[activeRestaurant];
restaurant.reviews.push(id);
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