Redux: Refactoring the Reducers

Share this video with your friends

Send Tweet

We will learn how to remove the duplication in our reducer files and how to keep the knowledge about the state shape colocated with the newly extracted reducers.

Ben
Ben
~ 8 years ago

looks like a given component (or container, or equivalent) could ultimately have its own reducer, doesn't it ?

Dan Abramov
Dan Abramov(instructor)
~ 8 years ago

If your components map 1:1 to reducers, maybe you don’t need Redux, and could use Redux state model instead :-). In this tutorial, the structure of components doesn’t neatly map to the structure of reducers. This has benefits such as ensuring entities are never duplicated in the state, but it also means components do not “have” their own reducers.

Puneeth
Puneeth
~ 8 years ago

Here you mention we write the selector function in the same file as the reducer. But if we were to make use of selector library like reselect, should the selector functions be written in a separate file? What would be a good way to go about it? Thanks