Skip to content

Hw 4#44

Open
boombarashk wants to merge 5 commits into
romabelka:masterfrom
boombarashk:HW-4
Open

Hw 4#44
boombarashk wants to merge 5 commits into
romabelka:masterfrom
boombarashk:HW-4

Conversation

@boombarashk
Copy link
Copy Markdown

No description provided.

const { articles, openItemId, toggleItem } = this.props
console.log('---', 'rendering ArticlList')
const articleElements = articles.map(article =>
const articleElements = Object.values(articles).map(article =>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Лучше селектор, который достанет их в виде массива

}

export default store => next => action => {
if (action.type === ADD_COMMENT) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

const randomId = shuffle((new Date()).toLocaleString('en-US').split('').filter((symbol)=> {
return symbol !== ' '
})).join('')
action.payload.data['id'] = randomId
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

лучше не мутировать payload, мало-ли что там станут передавать

Comment thread src/reducer/articles.js

case ADD_COMMENT:
let comments = articlesState[payload.data.articleid].comments
typeof comments !== 'undefined' ? comments.push(payload.data.id) : articlesState[payload.data.articleid].comments = new Array(payload.data.id)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

здесь ты мутируешь стейт и ничего не возвращаешь

Comment thread src/reducer/comments.js

case ADD_COMMENT:
const {id, user, text} = payload.data
commentsState[id] = {id: id, user: user, text: text}
Copy link
Copy Markdown
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