Reputation: 646
I want to create a filter for some set of data. Say, it's similar to https://www.npmjs.com/ "Find packages" search bar but without any AJAX calls. All data set I have when application is loaded.
So, I've got some "allPackages" object with all entities user can search through and "filteredPackages" which are being recalculated every time user changes search bar text.
How to achieve such behaviour with Redux paradygm? If I create "filteredPackages", how do I pass there "allPackages" data? AFAIK, combineReducers function doesn't allow that.
Upvotes: 0
Views: 159
Reputation: 67469
Per (Computing Derived Data), the general suggestion is to store the minimal amount of information needed in your state. Also, per (Redux FAQ), you are encouraged to store your data normalized. So, you might have your list of all items in state, and a field describing what type of filter you have applied. Then, in your connected components, you could use a "selector" function to run the appropriate filter against the list of all items.
The Redux Todo example demonstrates this type of approach as well: Redux Todos
Upvotes: 1