Answer the question
In order to leave comments, you need to log in
How to correctly pass parameters to reselect?
in store such branches:
store: {
posts: [{ id: '300', name: 'Название поста' }],
comments: [{ id: '10000', POST_ID: 300, 'title':'Всем привет' }],
},
export const getAllCommentsSelector = state => state.comments; // берем все комменты
export const getCurrentIDSelector = (state, props) => props.id; //это ID нашей статьи, напомню что вызываем Connect из всех статей
export const getCountByGroupID = createSelector(
getAllCommentsSelectorSelector,
getCurrentIDSelector,
(Comments, ID) => Comments.filter(el => el.POST_ID === ID).length,
); // тут получаем поличество комментариев для статьи
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question