Skip to content

Hometask5#76

Open
sergeyBreslavets wants to merge 11 commits intoromabelka:masterfrom
sergeyBreslavets:hometask5
Open

Hometask5#76
sergeyBreslavets wants to merge 11 commits intoromabelka:masterfrom
sergeyBreslavets:hometask5

Conversation

@sergeyBreslavets
Copy link

No description provided.

@sergeyBreslavets
Copy link
Author

я смог добавить в в статью новый комент (новый коммент появиться если скрыть и открыть коммент ) но как вызвать обновление потом не понял (


<Article
// article={article} /// это точно наверно не надо
id={article.id}
Copy link
Owner

Choose a reason for hiding this comment

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

не очень зачем это

if (!articles.length) return <h3>No Articles</h3>
const articleElements = articles.map((article) => <li key={article.id}>
<Article article={article}
const articleElements = Object.values(articles).map((article) => <li key={article.id}>
Copy link
Owner

Choose a reason for hiding this comment

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

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


console.log("new id" + randId())

action.payload.id = randId()
Copy link
Owner

Choose a reason for hiding this comment

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

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

// console.log(randId()) // для теста


if (action.type === ADD_NEW_COMMENT) {
Copy link
Owner

Choose a reason for hiding this comment

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

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

// console.log(store)
// console.log(store.getState().comments)
// console.log( Object.key(store.getState().comments).reduce( ( obj ) ) )
console.log(Object.values(store.getState().comments).length)
Copy link
Owner

Choose a reason for hiding this comment

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

Не надо в редюсерах к стору обращаться. Все необходимое у тебя в аргументах


const enhancer = composeEnhancers(
applyMiddleware(logger)
applyMiddleware(logger, newIdComment)
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