W
W
Worddoc2019-06-21 12:30:14
JavaScript
Worddoc, 2019-06-21 12:30:14

Reselect: how to cache data written to reducer?

I try reselect and the problem immediately arose: data polling works. Almost every time the same data arrives in the reducer - the component rerenders using this data. I try to cache this data using the selector - it doesn't work - the rerender still happens. What is wrong in this code?

function getAllTickets(reducer) {
    return reducer.get('tickets');
}

export const allTicketsSelector = createSelector([getAllTickets], items => items);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-06-21
@Worddoc

By default, createSelector uses the shallow comparison function. If you want to do a deep comparison, use createSelectorCreator and your comparison function. There is an example in the documentation .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question