Reputation: 511
What would be the preferred way of making the redux reducer that will support multiple API requests and their result? To be clear, if I have a list of popular movies, upcoming movies, and new movies (all of them can be paginated) how I should configure my reducer in a best practice manner? I should support all states of the request, pending, fulfilled, rejected. Should I make one reducer or every feature should have its own reducer? All results will be displayed on the same page. Thank you.
Upvotes: 2
Views: 1342
Reputation: 90
If the popular movies, upcoming movies, and new movies are all different formats then you can make 3 reducers and combine them like so: https://redux.js.org/api/combinereducers/
If they are all the same format but with a property that specifies which movies are popular, upcoming, new, etc. Then you can make one reducer for the format "movies" and use that instead.
Upvotes: 2