Skip to content

Conversation

@nikolaySolodkiy
Copy link

Не удалось сделать HT4.2 Переписать articles аналогично comments (id -> article)
Ломается приложение, не смог разобраться как переделать. Остальные пункты сделал как смог

export default (store) => (next) => (action) => {
const { type, payload } = action
let uniqueCommentId
if (type === 'ADD_COMMENT') {
Copy link
Owner

Choose a reason for hiding this comment

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

через мидлвары будет проходить каждый экшин, они должны быть максимально общими, завязывать на конкретные экшины - не лучшее решение

return articlesState.filter((article) => {
if (article.id === payload.articleId) {
if (article.comments) {
article.comments.push(payload.commentId)
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