The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Redux: Colocating Selectors with Reducers

Redux: Colocating Selectors with Reducers

4:52
We will learn how to encapsulate the knowledge about the state shape in the reducer files, so that the components don’t have to rely on it.
Watch this lesson now
Avatar
egghead.io

We will learn how to encapsulate the knowledge about the state shape in the reducer files, so that the components don’t have to rely on it.

Avatar
Kristian

In a large application won't this mean there are possibly hundreds of selector functions in the root reducer?

I wonder if there is a way to import selectors from child reducers via an import * and apply the relevant slice of the state tree to them?

Avatar
Afzal

In reducers/index.js why do we not have curly braces here?

export const getVisibleTodos = (state, filter) =>
    fromTodos.getVisibleTodos(state.todos, filter);

If I put curly braces it gives me an error (cannot read map of undefined in todolist ie not getting todos in todolist.js) and doesn't work

// doesn't work
export const getVisibleTodos = (state, filter) => {
    fromTodos.getVisibleTodos(state.todos, filter);
};
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?