Answer the question
In order to leave comments, you need to log in
Can redux search and return an object from a state?
I just started to understand redux and react, I'm doing something for the test. And I want to implement some functionality for searching for the necessary elements in an array, so the essence of the question is, should the reducer do this, or should the component itself do this? That is, can the reducer filter the state and return only the elements I need?
Answer the question
In order to leave comments, you need to log in
Your question is a little vague (it's not entirely clear "filter the state .."), but if I understand you correctly, in your reducer you can prepare all the data so that they can only be displayed in the component. This is what the reducer is for.
For example, there is a certain backend which returns you the answer. You only need a couple of fields in the component from this answer. Therefore, it is worth returning only the necessary data from the reducer at once.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question