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

Hm4 kazmin #40

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

Hm4 kazmin #40

wants to merge 2 commits into from

Conversation

kazminigor1988
Copy link

No description provided.

return TYPE_ARTICLE
}

constructor(id, type = CommentHolder.TYPE_ARTICLE) {
Copy link
Owner

Choose a reason for hiding this comment

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

Как по мне - перемудрил с этим. Тем более ты пользуешься тем, что у нас key={id}, но ты не можешь быть в этом уверен в самом компоненте.

Copy link
Author

Choose a reason for hiding this comment

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

тогда можно просто передавать entityId + entityOwner (entityHolder, etc.)

потому что если мы не будем делать абстракцию и потом компонент коментариев будет использоватся например списком новостей, прийдется компонент коментариев рефакторить

export default (store) => (next) => (action) => {
const { type, payload } = action

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.

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

Copy link
Author

Choose a reason for hiding this comment

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

тогда просто подмешивать в каждый екшене в payload generatedId ?

const articleId = payload.holder.getId()
const article = articleState[articleId]

article.comments = [].concat(article.comments)
Copy link
Owner

Choose a reason for hiding this comment

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

article тоже по ссылке не меняй

Copy link
Author

@kazminigor1988 kazminigor1988 May 31, 2018

Choose a reason for hiding this comment

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

лучшее решение думаю deepClone (lodash), и в коменты подмешивать новый commentId

ну и если говорить о разбиении, comments - не лучшний нейминг, скорее commentIds

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