Skip to content

Ht4#46

Open
mas-student wants to merge 4 commits into
romabelka:masterfrom
mas-student:HT4
Open

Ht4#46
mas-student wants to merge 4 commits into
romabelka:masterfrom
mas-student:HT4

Conversation

@mas-student
Copy link
Copy Markdown

HT4
как получить текущую статью?

const options = articles.map(article => ({
label: article.title,
value: article.id
const options = Object.keys(articles).map(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/middlewares/uuid.js
}
uuid = s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();

action.payload.uuid = uuid;
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/middlewares/uuid.js
@@ -0,0 +1,14 @@
export default store => next => action => {
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.

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

Comment thread src/reducer/articles.js
switch (type) {
case ADD_COMMENT:
let id = Object.keys(articlesState)[0]
articlesState[id].comments.push(action.payload.uuid)
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
comment['id'] = action.payload.uuid
comment['text'] = action.payload.text
comment['user'] = 'USER1'
commentsState[action.payload.uuid] = 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.

И здесь не мутируй

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.

3 participants