V
V
Vadim Stepanenko2021-07-18 18:38:41
React
Vadim Stepanenko, 2021-07-18 18:38:41

When should you use reselect?

Hey!
I understand with reselect and ran into the question - in what cases do you need to create a createSelector selector?

it is clear that you do not need to use createSelector for useSelector((state) => state.settings.form). the doc says that createSelector should be used for computed data (filter, map, reduce, etc.)

, but for example, such a selector (state) => state.settings[CONST_SECTION].list is computed and is it necessary to create a selector for it? Or if a prop is passed instead of CONST_SECTION?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max, 2021-07-18
@Vadim1899

A reselect is needed in cases where the profiler shows that the component is being redrawn, despite the fact that the data in the component has not changed.
Examples of when this might be: A function inside useSelector creates and returns a new object/array. The function (state) => state.settings[CONST_SECTION].listis not

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question